#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:32000000")
#pragma GCC optimize("O3")
using namespace std;
int n;
int add[1000005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  cout.precision(8);
  srand(time(0));
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t, c;
    cin >> t >> c;
    add[t] += c;
  }
  int maxsz = 0, maxtime = 0, t = 0;
  for (int i = 0; i < 1000005; i++) {
    t = max(0, t - 1);
    t += add[i];
    if (t) {
      maxsz = max(maxsz, t);
      maxtime = max(maxtime, i + t);
    }
  }
  cout << maxtime << " " << maxsz;
  return 0;
}
