#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, i, sum, ans;
  cin >> n;
  vector<pair<long long, long long>> v(n);
  for (i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
  sum = v[0].second;
  ans = sum;
  for (i = 1; i < n; i++) {
    if (sum != 0) sum -= (v[i].first - v[i - 1].first);
    if (sum < 0) sum = 0;
    sum += v[i].second;
    ans = max(ans, sum);
  }
  cout << v[n - 1].first + sum << " " << ans << endl;
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
