//templete
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<n;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int N;
    ll A,B;
    ll ans=0;

    cin>>N;
    rep(i,N){
        cin>>A>>B;
        ans+=B*(B+1)/2-A*(A-1)/2;
    }
    cout<<ans;
    return 0;
}
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (int)(a); i <= (int)(b); i++)

struct ad{
    int left, up, right, down;
};

int time_start;
int Num;
std::vector<ad> ads;
std::vector<std::pair<ad,int>> ads_start;

void in(){
    std::cin >> Num;
    ads.resize(Num);
    ads_start.resize(Num);
    rep(i,0,Num-1){
        std:: cin >> ads[i].left >> ads[i].up;
        ads[i].right = ads[i].left + 1;
        ads[i].down = ads[i].up + 1;
        ads_start[i].first = ads[i];
        std::cin >> ads_start[i].second;
    }
}

void make_randomcase(){
    
}

bool is_collision(int N){
    if(ads[N].left<0||ads[N].up<0||ads[N].right>10000||ads[N].down>10000) return true;
    rep(i,0,Num-1){
        if(i==N) continue;
        if( std::max(ads[i].left,ads[N].left) < std::min(ads[i].right,ads[N].right) && std::max(ads[i].up,ads[N].up) < std::min(ads[i].down,ads[N].down) ){
            return true;
        }
    }
    return false;
}

int score(){
    long double point=0;
    rep(i,0,Num-1){
        point+=1.0-pow(1-1.0*std::min(ads_start[i].second,(ads[i].right-ads[i].left)*(ads[i].down-ads[i].up))/std::max(ads_start[i].second,(ads[i].right-ads[i].left)*(ads[i].down-ads[i].up)),2);
    }
    point *= 1e9;
    point /= Num;
    return round(point);
}

//ランダムに広げる（広げて得をして、なおかつできるものだけ広げる）

void solve(){
    std::vector<std::vector<int>> delta(4,std::vector<int> (4,0));
    delta[0][0] = delta[1][1] = -1;
    delta[2][2] = delta[3][3] = 1;
    std::vector<ad> best_ads(Num);
    int bestscore = score();
    rep(_,0,44){
        rep(i,0,Num-1){
            ads[i] = ads_start[i].first;
        }
        time_start = clock();
        while(clock() - time_start < 100000){
            int select = random()%Num;
            int direction = random()%4;
            int stretch = ( 10 - (clock() - time_start) / 10000 ) * ( random()%10 + 1 );
            ads[select].left += stretch * delta[direction][0];
            ads[select].up += stretch * delta[direction][1];
            ads[select].right += stretch * delta[direction][2];
            ads[select].down += stretch * delta[direction][3];
            if(is_collision(select)||(ads[select].right-ads[select].left)*(ads[select].down-ads[select].up)>ads_start[select].second*std::min((long)10, 7 + ( clock() - time_start ) / 20000) / 10){
                ads[select].left -= stretch * delta[direction][0];
                ads[select].up -= stretch * delta[direction][1];
                ads[select].right -= stretch * delta[direction][2];
                ads[select].down -= stretch * delta[direction][3];
            }
        }
        if(bestscore < score()){
            bestscore = score();
            best_ads = ads;
        }
    }
    ads = best_ads;
}

void out(){
    rep(i,0,Num-1){
        std::cout << ads[i].left << ' ' << ads[i].up << ' ' << ads[i].right << ' ' << ads[i].down << '\n';
    }
}

int main() {
    srand((unsigned int)time(NULL));
    time_start = std::clock();
    in();
    solve();
    out();
    std::cerr << score() << std::endl;
}