#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int Delta[10000000];
int Act[10000000];

int main()
{
    vector <pair <int, int>> R;
    vector <pair <int, int>> Merged;

    int N, T1, T2;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> T1 >> T2;
        R.push_back({T1 - 1, 1});
        R.push_back({T2 - 1, -1});
    }

    sort (R.begin(), R.end());

    int MaxQ = -100;
    int CQ = 0;
    int MaxQT = 0;

    Merged.push_back(R[0]);
    for (int i = 1; i < R.size(); i++)
    {
        if (R[i].first != Merged.back().first)
        {
            Merged.push_back(R[i]);
        }
        else
        {
            Merged[Merged.size() - 1].second += R[i].second;
        }
    }

    for (const auto &t : Merged)
    {
        CQ += t.second;
        MaxQ = max(MaxQ, CQ);
    }

    for (int i = 0; (i + 1) < Merged.size(); i++)
    {
        CQ += Merged[i].second;
        if (CQ == MaxQ)
        {
            MaxQT += Merged[i + 1].first - Merged[i].first;
        }
    }

    /*for (const auto &t : R)
    {
        cout << t.first << " " << t.second << endl;
    }
    cout << endl;

    for (const auto &t : Merged)
    {
        cout << t.first << " " << t.second << endl;
    }*/

    cout << MaxQ << endl;
    cout << MaxQT << endl;
}
