#include "bits/stdc++.h" //custom precompiled stdc++.h header :)
using namespace std;

#define ll                  long long int
#define Print(x)            cout << x << endl
#define PrintAns(x)         cout << x << endl; return
#define PrintPrec(x, y)     cout << fixed << setprecision(y) << x << endl;
#ifdef SUBLIME
#define deb(x)              cout << #x << ": " << x << endl;
#define deb2(x, y)          cout << #x << ": " << x << ", " << #y << ": " << y <<endl
#else
#define deb(x)              //luKaS iS No0b
#define deb2(x, y)          //XD
#endif
#define cint(x)             int x; cin >> x
#define cll(x)              ll x; cin >> x
#define cstring(x)          string x; cin >> x
#define pb                  push_back
#define mp                  make_pair

typedef vector<int>         vi;
typedef vector<ll>          vll;
typedef vector<string>      vs;

const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;

//    cint(n);
//    vi vec(n);
//    for(int i = 0; i < n; i++){
//        cin >> vec[i];
//    }


void test_case() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> b >> a;
        ans += a * (a + 1) / 2 - b * (b + 1) / 2 + b;
    }
    Print(ans);
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifdef SUBLIME
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    long long t = 1;
    ///cin >> t;
    while (t--)
    {
        test_case();
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;


int main()
{
   ll n,i;
   cin>>n;
   ll A[n];
   ll S=0;
   for(i=0;i<n;i++)
   {
       cin>>A[i];
       S+=A[i];
   }
   sort(A,A+n);
   ll prev=0,ans=0;
   for(i=0;i<n;i++)
   {
       ll p1,p2;
       prev+=A[i];
       p1=(i+1)*A[i]-prev;
       p2=(S-prev)-(n-i-1)*A[i];
       ans+=(p1+p2);
   }
   ans/=2;
   cout<<ans;
}
