#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n;
struct type
{
long long w,x,y;
}p[500001];
int cmp(const void *a,const void *b)
{
return ((type *)a)->x-((type *)b)->x;
}
long long solve()
{
qsort(p+1,n,sizeof(p[0]),cmp);
long long cost=0,ans;
int q=p[1].w,h=0,i;
for(i=2;i<=n;i++)
{
cost+=(p[i].x-p[1].x)*p[i].w;
h+=p[i].w;
}
ans=cost;
for (i=2;i<=n;i++)
{
cost+=(p[i].x-p[i-1].x)*q;
cost-=(p[i].x-p[i-1].x)*h;
q+=p[i].w;
h-=p[i].w;
if(cost<ans)
ans=cost;
}
return ans;
}
int main()
{
int i;
long long ans;
freopen("ballc.in","r",stdin);
freopen("ballc.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&p[i].w);
for(i=1;i<=n;i++)
scanf("%d%d",&p[i].x,&p[i].y);
ans=solve();
for(i=1;i<=n;i++)
swap(p[i].x,p[i].y);
ans+=solve();
printf("%lld.00\n",ans);
return 0;
}