#include<bits/stdc++.h>
#define ll long long int

using namespace std;
// ll n;

int main()
{
	 #ifndef ONLINE_JUDGE
freopen("inn.txt", "r", stdin);
freopen("hell.txt", "w", stdout);
#else
#endif  
ll   n;
cin>>n;
ll   ans=0;
while(n--)
{
	ll   a,b;
	cin>>a>>b;
	ans+=(b*(b+1)/2-a*(a-1)/2);
}
cout<<ans<<endl;




}
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  vector<long long> a(n);
  map<int,long long> cnt;
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    cnt[a.at(i)]++;
  }
  long long ans=n*(n-1)/2;
  
  auto begin = cnt.begin(), end = cnt.end();
  for (auto iter = begin; iter != end; iter++) {
    long long x=iter->second;
    ans-=x*(x-1)/2;
  }
  cout<<ans<<endl;
}