#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = 1005;
int t[maxn], c[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t[i] >> c[i];
  }
  int cnt = 0;
  int ma = 0;
  for (int i = 0; i < n; i++) {
    cnt = max(cnt, 0);
    cnt += c[i];
    ma = max(ma, cnt);
    if (i + 1 < n) {
      cnt -= t[i + 1] - t[i];
    }
  }
  cout << cnt + t[n - 1] << " " << ma << endl;
  return 0;
}
