//Just have Patience + 1...
#include<bits/stdc++.h>
using namespace std;

#define tarzan ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long 

int rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
int cc[] = {1, 1, 0, -1, -1, -1, 0, 1};

const int mod = 1e9 + 7;
const int N = 300050;

signed main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    tarzan;
    int test = 1;
    //cin >> test;
    while(test--) {
        int n;
        cin >> n;

        int ans = 0;
        vector<pair<int, int> > store(n);
        for(int i = 0; i < n; i++) {
            cin >> store[i].first >> store[i].second;
            ans += store[i].second;
        }

        sort(store.begin(), store.end());

        int mx = store[0].first + store[0].second;
        for(int i = 1; i < n; i++) {
            ans += max(0LL, store[i].first - mx);
            mx = max(mx, (store[i].first + store[i].second));
        }
        cout << ans << '\n';
    }
    return 0;
}
