#include <bits/stdc++.h>
using namespace std;
struct task {
  int time;
  int msgs;
  task(int t, int m) { time = t, msgs = m; }
};
bool sorter(task t1, task t2) { return t1.time < t2.time; }
int main() {
  int n;
  cin >> n;
  vector<task> tasks;
  for (int(i) = (0); (i) < (n); (i)++) {
    int time, msgs;
    cin >> time >> msgs;
    task t(time, msgs);
    tasks.push_back(t);
  }
  sort(tasks.begin(), tasks.end(), sorter);
  int mxMsgs = 0, lastSent = 0;
  int queueSize = 0;
  for (int(i) = (0); (i) < (n); (i)++) {
    if (queueSize > 0) queueSize -= 1;
    if (i > 0) {
      queueSize -= tasks[i].time - tasks[i - 1].time - 1;
      queueSize = max(queueSize, 0);
    }
    queueSize += tasks[i].msgs;
    mxMsgs = max(queueSize, mxMsgs);
  }
  lastSent = queueSize + tasks[n - 1].time;
  cout << lastSent << " " << mxMsgs << endl;
  return 0;
}
