#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
pair<int, int> L[maxn];
int main() {
  int n, sz = 0, ms = 0, tot = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &L[i].first, &L[i].second);
  }
  sort(L, L + n);
  int p = 0;
  for (int t = 1; t <= L[n - 1].first; ++t) {
    sz = max(0, sz - 1);
    while (p < n && L[p].first == t) sz += L[p++].second;
    ms = max(ms, sz);
  }
  printf("%d %d\n", sz + L[n - 1].first, ms);
  return 0;
}
