#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long n;
  cin >> n;
  vector<pair<long long, long long> > p;
  for (long long i = 0; i < n; i++) {
    long long t, c;
    cin >> t >> c;
    p.push_back(make_pair(t, c));
  }
  long long now = 1;
  long long maximum = 0;
  long long times = 0;
  for (long long i = 0; i < n - 1; i++) {
    now = now > 0 ? --now : now;
    now += p[i].second;
    maximum = max(maximum, now);
    now -= min(now, p[i + 1].first - p[i].first - 1);
  }
  times = p[n - 1].first;
  now = now > 0 ? --now : now;
  now += p[n - 1].second;
  maximum = max(maximum, now);
  times += now;
  cout << times << ' ' << maximum;
  return 0;
}
