program groupa;
var
i,j,k,n:longint;
a:array[1..50]of longint;
l,r,o,p:longint;
max:longint;
begin
assign(input,'groupa.in');
reset(input);
assign(output,'groupa.out');
rewrite(output);
readln(n);
max:=0;
for i:=1 to n do
begin
read(a[i]);
max:=max+a[i];
end;
readln;
readln(l,r);
if (max<l*n) or (max>r*n) then
begin
writeln('-1');
close(input);
close(output);
halt;
end;
o:=0;
p:=0;
for i:=1 to n do
if a[i]<l then o:=o+l-a[i]
else if a[i]>r then p:=p+a[i]-r;
if o>p then writeln(o)
else writeln(p);
close(input);
close(output);
end.