#include<cstdio>
using namespace std;
int cf[1000010];
int main()
{
	int n;
	scanf("%d",&n);
	while(n--)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		cf[l]++;
		cf[r+1]--;
	}
	long long cnt=0,ans=0;
	for(int i=1;i<=1000000;i++)
	{
		cnt+=cf[i];
		ans+=cnt*i;
	}
	printf("%lld",ans);
}
#include <bits/stdc++.h>
using namespace std;


using ll = long long;
using ld = long double;
template <class T> using pq  = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }


constexpr ll MOD   = 1000000007;
/* constexpr ll MOD   = 998244353; */
constexpr ll MAX   = 5e5;
constexpr ll INF   = 1e9;
constexpr ll INFLL = 1e18;
constexpr ld EPS   = 1e-10;


int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;

  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;

    ans += (b - a + 1) * (a + b) / 2;
  }

  cout << ans << endl;

  return (0);
}
