#include<bits/stdc++.h>
using namespace std;

#define endl "\n"
int n;
vector<pair<int, int>> events;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i = 0; i < n; i++){
        int a, b;
        cin>>a>>b;
        events.push_back({a, 1});
        events.push_back({b, -1});
    }
    sort(events.begin(), events.end());
    long long curr = 0, maxBr = 0, ans = 0;
    for(long long i = 0; i < events.size(); i++){
        curr += events[i].second;
        maxBr = max(maxBr, curr);
    }
    curr = 0;
    int start;
    for(long long i = 0; i < events.size(); i++){
        curr += events[i].second;
        if(events[i].second == 1 && curr == maxBr){
            start = events[i].first;
        }
        if(events[i].second == -1 && curr == maxBr - 1){
            ans += events[i].first - start;
        }

    }
    cout<<maxBr<<endl<<ans<<endl;
}
