#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
ll a[200100];
void solve(int T)
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        //cout<<(a[i]*-1ll*(ll)(n-i)+a[i]*(ll)(i-1))<<endl;
        sum+=(a[i]*-1ll*(ll)(n-i)+a[i]*(ll)(i-1));
    }
    cout<<sum;
}
//#define ONLINE_JUDGE;
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("lotato.in","r",stdin);
    freopen("lotato.out","w",stdout);
    #endif
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }
    return 0;
}
#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
  int n;
  cin >> n;
  ll a, b, ans = 0;
  rep(i, 0, n) {
    cin >> a >> b;
    ll num = (b - a) + 1;
    ans += num * (a + (a + num - 1)) / 2;
  }

  cout << ans << endl;

  return 0;
}
