var
n,x,l,i,r,up,down:longint;
a:array[0..100]of longint;
procedure init;
var
i,x:longint;
begin
assign(input,'groupa.in'); reset(input);
assign(output,'groupa.out'); rewrite(output);
readln(n);
x:=0;
for i:=1 to n do
begin
read(a[i]);
x:=x+a[i];
end;
read(down,up);
if (x<down*n)or(x>up*n) then
begin
writeln(-1);
close(input);
close(output);
halt;
end;
end;
begin
init;
for i:=1 to n do
begin
if a[i]>up then inc(r,a[i]-up);
if a[i]<down then inc(l,down-a[i]);
end;
if r>l then writeln(r)
else writeln(l);
close(input);
close(output);
end.