// In the name of Allah.
// We're nothing and you're everything.
// Ya Ali!

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MAX_N = 1e5 + 14;
int n;

struct City {
    int a, c;

    bool operator<(const City &rhs) const {
        return a < rhs.a;
    }
} city[MAX_N];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> city[i].a >> city[i].c;
        ans += city[i].c;
    }
    sort(city, city + n);
    int max_a_plus_c = city[0].a + city[0].c;
    for (int i = 1; i < n; ++i) {
        if (max_a_plus_c < city[i].a)
            ans += city[i].a - max_a_plus_c;
        max_a_plus_c = max(max_a_plus_c, city[i].a + city[i].c);
    }
    cout << ans << '\n';
}