#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  int p = 0;
  int max = 0;
  for (int i = 0; i < a[n - 1]; i++) {
    if (count > 0) count--;
    if (a[p] - 1 == i) {
      count += b[p];
      p++;
    }
    if (max < count) max = count;
  }
  cout << count + a[n - 1] << ' ' << max << endl;
  return 0;
}
