var n,i,j,k,m,min,max,l,r:longint;
a:array[0..51]of int64;
tot,s:int64;
begin
assign(input,'groupa.in');reset(input);
assign(output,'groupa.out');rewrite(output);
readln(n);
tot:=0; s:=0;
for i:=1 to n do
begin
read(a[i]);tot:=tot+a[i];
end;
readln(l,r);
if ((tot / n) <l)or((tot / n)>r) then
begin writeln('-1');close(input);close(output);halt; end;
tot:=0; s:=0;
for i:=1 to n do
begin
if a[i]<l then tot:=tot+l-a[i];
if a[i]>r then s:=s+a[i]-r;
end;
if tot<s then tot:=s;
writeln(tot);
close(input);close(output);
end.