#include<bits/stdc++.h>
using namespace std;

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

    int n;
    cin>>n;

    vector<pair<int, int>> vp;
    long long ans = 0;

    for (int i=0; i<n; i++) {
        int x, y;
        cin>>x>>y;
        ans += y;
        vp.push_back({x, y});
    }
    sort(vp.begin(), vp.end());
    int done = vp[0].first;

    for (auto [l, x]: vp) {
        int r = l+x;
        if (done < l)   ans += l-done;
        done = max(r, done);
    }
    cout<<ans<<endl;


}
