#include <bits/stdc++.h>
namespace solution {
class ISolution {
 public:
  virtual void init(){};
  virtual bool input() { return false; };
  virtual void output(){};
  virtual int run() = 0;
};
}  // namespace solution
namespace solution {}
namespace solution {
using namespace std;
const int SIZE = 1011;
const int MAX_TIME = 1000011;
int n;
int T[SIZE];
int C[SIZE];
long long X[MAX_TIME];
class Solution : public ISolution {
 public:
  bool input() {
    if (!(cin >> n)) return false;
    for (int i = 0; i < n; ++i) cin >> T[i] >> C[i];
    return true;
  }
  void solve() {
    fill(X, X + MAX_TIME, 0);
    for (int i = 0; i < n; ++i) X[T[i]] += C[i];
    long long t = 0;
    long long res = 0;
    long long sum = 0;
    for (long long i = 0; i < MAX_TIME; ++i) {
      if (sum > 0) {
        t = max(t, i);
        sum--;
      }
      sum += X[i];
      res = max(res, sum);
    }
    if (sum) {
      t += sum;
    }
    cout << t << " " << res << endl;
  }
  int run() {
    while (init(), input()) {
      solve();
      output();
    }
    return 0;
  }
};
}  // namespace solution
int main() { return solution::Solution().run(); }
