uses math;
var
n:shortint;
l,r,i,j:longint;
ans,sum:int64;
a:array[1..50] of longint;
begin
assign(input,'groupa.in');
assign(output,'groupa.out');
reset(input);
rewrite(output);
//while not(eof) do
//begin
read(n);
ans:=0;
for i:=1 to n do
begin
read(a[i]);
inc(ans,a[i]);
end;
read(l,r);
if (ans<l*n) or (ans>r*n) then
begin
writeln(-1);
exit;
end;
sum:=0;
ans:=0;
for i:=1 to n do
begin
if a[i]>r then
inc(ans,a[i]-r);
if a[i]<l then
inc(sum,l-a[i]);
end;
writeln(max(ans,sum));
//end;
close(input);
close(output);
end.