#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int n;
struct rect
{
int sort_y;
ll x,y;
}rec[100005];
bool cmp_x(const rect& r1,const rect& r2)
{
return r1.x > r2.x;
}
bool cmp_y(const rect& r1,const rect& r2)
{
return r1.y < r2.y;
}
struct bit
{
ll bit[(1<<17)+5];
void add(int pos,ll add)
{
for(int i=pos;i<=n;i+=i&-i) bit[i]+=add;
}
ll query(int pos)
{
ll res=0;
for(int i=pos;i>0;i-=i&-i) res+=bit[i];
return res;
}
}aibi,num,ai,bi;
int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%lld %lld",&rec[i].x,&rec[i].y);
}
sort(rec,rec+n,cmp_y);
for(int i=0;i<n;i++) rec[i].sort_y = i;
sort(rec,rec+n,cmp_x);
ll res = 0LL;
for(int i=0;i<n;i++)
{
ll c = rec[i].x;
ll d = rec[i].y;
int id = rec[i].sort_y+1;
ll v = num.query(n),v2 = num.query(id); v-=v2;
ll sum_aibi = aibi.query(n),sum2_aibi = aibi.query(id); sum_aibi-=sum2_aibi;
ll sum_ai = ai.query(n),sum2_ai = ai.query(id); sum_ai-=sum2_ai;
ll sum_bi = bi.query(n),sum2_bi = bi.query(id); sum_bi-=sum2_bi;
//bigger
res += sum_aibi + c*d*v - d*sum_ai - c*sum_bi;
//smaller
res += d*sum2_ai + c*sum2_bi - sum2_aibi - c*d*v2;
num.add(id,1);
aibi.add(id,c*d);
ai.add(id,c);
bi.add(id,d);
}
printf("%lld\n",res);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBwYWlyPGludCxpbnQ+IFA7CnR5cGVkZWYgbG9uZyBsb25nIGxsOwogCmludCBuOwpzdHJ1Y3QgcmVjdAp7CglpbnQgc29ydF95OwoJbGwgeCx5Owp9cmVjWzEwMDAwNV07CmJvb2wgY21wX3goY29uc3QgcmVjdCYgcjEsY29uc3Qgcm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