#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() { 
    vector<ll> rui(1000001);
    ll sum = 0;
    rep(i, 1000001){
        rui[i] = sum;
        sum += (i+1); 
    }

    int n;
    cin >> n;

    ll res = 0;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        res += rui[b] - rui[a-1];
    }

    cout << res << endl;
    return 0; 
}
#include<cstdio>
#include<algorithm>
using namespace std;

#define fi first
#define se second
#define rep(i, l, r) for(int i=(l), i##_end_=(r); i<=i##_end_; ++i)
#define fep(i, l, r) for(int i=(l), i##_end_=(r); i>=i##_end_; --i)
typedef long long ll;
template<class T>inline T fab(T x){ return x<0? -x: x; }
template<class T>inline T readin(T x){
    x=0; int f=0; char c;
    while((c=getchar())<'0' || '9'<c) if(c=='-') f=1;
    for(x=(c^48); '0'<=(c=getchar()) && c<='9'; x=(x<<1)+(x<<3)+(c^48));
    return f? -x: x;
}

const int maxn=2e5;

int a[maxn+5], n;

int cnt[205];

inline void input(){
    n=readin(1);
    rep(i, 1, n) a[i]=readin(1);
}

signed main(){
    input();
    rep(i, 1, n) ++cnt[a[i]%200];
    ll ans=0;
    rep(i, 1, n) ans+=cnt[a[i]%200]-1;
    ans>>=1;
    printf("%lld\n", ans);
    return 0;
}