#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[1000010];
long long n, sol, maxx, x, y, red;
char s[1000000 + 10];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    a[i] = make_pair(x, y);
  }
  for (int i = 1; i <= n; i++) {
    if (red + a[i - 1].first > a[i].first)
      red -= a[i].first - a[i - 1].first;
    else
      red = 0;
    red = red + a[i].second;
    maxx = max(maxx, red);
  }
  cout << red + a[n].first << " " << maxx;
  return 0;
}
