program groupa;
var
a:array [1..50] of longint;
n,l,r,num1,num2,num3,num4:longint;
f1,f2:text;
procedure init;
var i:longint;
begin
assign(f1,'groupa.in'); reset(f1);
assign(f2,'groupa.out'); rewrite(f2);
readln(f1,n);
for i:=1 to n do read(f1,a[i]);
readln(f1);
read(f1,l,r);
close(f1);
num1:=0;
num2:=0;
num3:=0;
num4:=0;
for i:=1 to n do begin
if a[i]<l then num1:=num1+(l-a[i]);
if a[i]>r then num2:=num2+(a[i]-r);
if (a[i]>l) then num3:=num3+(a[i]-l);
if (a[i]<r) then num4:=num4+(r-a[i]);
end;
end;
procedure play;
var l,r,k:longint;
begin
if (num1>num3)or(num2>num4) then writeln(f2,-1)
else begin
if num1=num2 then begin writeln(f2,num1); end;
if num1<num2 then begin writeln(f2,num2); end;
if num1>num2 then begin writeln(f2,num1); end;
end;
close(f2);
end;
begin
init;
play;
end.