#include <bits/stdc++.h>
using namespace std;
int main() {
    // your code goes here
    ios::sync_with_stdio(0);
    int n;
    cin>>n;
    int score[n],pos[n];
    for (int i = 0; i < n; i++) {
        cin>>score[i]>>pos[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans=ans+abs(pos[i]-pos[j])*max(score[i],score[j]);
        }
    }
    cout<<ans;
    return 0;
}