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