#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 1e5 + 10;
int n;
int main() {
  cin >> n;
  long long ans1 = 0, ans2 = 0, t = 0, last;
  for (int i = 1; i <= n; i++) {
    long long a, b;
    cin >> a >> b;
    t = max(t + b, a + b);
    ans2 = max(ans2, t - a);
  }
  ans1 = t;
  cout << ans1 << " " << ans2 << endl;
  return 0;
}
