/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// Actual solution is at the bottom

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstdint>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>
//#include "../atcoder/all"

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef int64_t int64;
typedef pair<int, int> ii;

class CZadachaKommivoyazhyora {
 public:
  void solveOne() {
    int n;
    cin >> n;
    vector<ii> v(n);
    for (auto& p : v) {
      cin >> p.first >> p.second;
    }
    sort(all(v));
    int64 extra = 0;
    int64 upto = v[0].first;
    for (auto p : v) {
      if (p.first > upto) {
        extra += p.first - upto;
      }
      upto = max(upto, (int64) p.first + p.second);
    }
    for (auto p : v) extra += p.second;
    cout << extra << "\n";
  }

  void solve() {
    int nt = 1;
    for (int it = 0; it < nt; ++it) {
      solveOne();
    }
  }
};


int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    CZadachaKommivoyazhyora solver;


    solver.solve();
    return 0;
}
