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