#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
vector<pair<int, int> > task;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    task.push_back(make_pair(a, b));
  }
  long long t = 0, s = 0, os = 0;
  for (int i = 0; i < n; i++) {
    s -= max(0ll, task[i].first - t);
    s = max(s, 0ll);
    t = max(t, (long long)task[i].first);
    s += task[i].second;
    os = max(os, s);
  }
  t += s;
  printf("%I64d %I64d\n", t, os);
  return 0;
}
