program ballc;
var
n,i,j,k,xx,yy:longint;
px,py,min: extended;
w,x,y:array[0..30000]of extended;
f:array[0..3000,0..30000]of extended;
Begin
assign(input,'ballc.in');reset(input);
assign(output,'ballc.out');rewrite(output);
readln(n);
for i:=1 to n do read(w[i]);readln;
px:=0;py:=0;
for i:=1 to n do
begin
readln(x[i],y[i]);
if x[i]>px then px:=x[i];
if y[i]>py then py:=y[i];
end;
xx:=round(px);py:=round(py); min:=99999999;
for i:=0 to xx do
for j:=0 to yy do
begin
for k:=1 to n do
f[i,j]:=f[i,j]+w[k]*(abs(x[k]-i)+abs(y[k]-j));
if min>f[i,j] then min:=f[i,j];
end;
writeln(min:0:2);
close(input);close(output);
end.