#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int t, c, prev1 = 0, prev2 = 0, cnt = 0, xnt1 = 0;
  int ans = 0, sz = 0;
  vector<int> x1;
  vector<int> x2;
  while (n--) {
    cin >> t >> c;
    if (prev1 != 0) {
      sz -= min(sz, t - prev1);
    }
    sz += c;
    ans = max(ans, sz);
    if (prev1 != 0) x2.push_back(t - prev1);
    x1.push_back(c);
    prev1 = t;
  }
  cnt += prev1;
  int gg1 = 0, gg2 = 0;
  int buildup = 0;
  for (int i = 0; i < x1.size() - 1; i++) {
    buildup += x1[i];
    { buildup -= min(buildup, x2[i]); }
  }
  cnt += buildup;
  reverse(x1.begin(), x1.end());
  cnt += x1[0];
  cout << cnt << ' ' << ans;
}
