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