uses math;
var
n:shortint;
l,r,i,j:longint;
ans,sum:int64;
a:array[1..50] of longint;
procedure sort(l,r:shortint);
var
i,j,x:shortint;
y:longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if i<=j then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
dec(j);
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
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.