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