#include <iostream>
#include <algorithm>

constexpr int N = 100005;

int n;
struct node {
    long long a, b;
} a[N];

int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
    std::cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; ++i) std::cin >> a[i].a >> a[i].b, ans += a[i].b;
    std::sort(a + 1, a + n + 1, [](node a, node b) { return a.a < b.a; });
    int now = 1;
    long long max = a[1].a + a[1].b;
    while (now <= n) {
        int x = now + 1;
        while (x <= n && a[x].a + a[x].b <= max) ++x;
        if (x > n) break;
        ans += std::max(a[x].a - max, 0ll);
        max = a[x].a + a[x].b;
        now = x;
    }
    std::cout << ans << '\n';
    return 0;
}
