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