#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

vector<pair<int, bool>> edg;

int main () {
//    ios_base::sync_with_stdio(0);
//    cin.tie(0);

    int n, max_c = 0, max_c_num = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        edg.push_back(make_pair(x, 0));
        edg.push_back(make_pair(y, 1));
    }
    sort(edg.begin(), edg.end());

    int cur_ln = 0;
    for (int i = 0; i < edg.size(); i++) {
        if (cur_ln == max_c) {
            max_c_num += edg[i].first - edg[i - 1].first;
        }
        if (cur_ln > max_c) {
            max_c = cur_ln;
            max_c_num = edg[i].first - edg[i - 1].first;
        }

        if (edg[i].second) {
            cur_ln--;
        } else {
            cur_ln++;
        }
    }
    cout << max_c << "\n" << max_c_num;
}
