#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long n, ng = 0, br = 0;
long a[10000020], ps[10000020];
vector<pair<long, long>> event;
//bool tukOtpaadaLi[10000020];
pair<long, long> interval[50000];
bool bachkaLi(long ind){
    //if(tukOtpaadaLi[ind]){
        return 0;
   // }
   // if(ps[ind]==ng){
        return 1;
   // }
    return 0;
}
int main(){
    cin>>n;
    for(long i=0; i<n; i++){
        cin>>interval[i].first>>interval[i].second;
    }
    sort(interval, interval+n);
    long rn = 0;
    for(long i=0; i<n; i++){
        //cout<<interval[i].first<<" "<<interval[i].second<<"\n";
        //a[interval[i].first] += a[interval[i].first-1];
        event.push_back({interval[i].first, 1});
        event.push_back({interval[i].second, -1});
        //tukOtpaadaLi[interval[i].second] = true;
    }
    sort(event.begin(), event.end());
    for(int i=0; i<event.size(); i++){
        //cout<<event[i].first<<" "<<event[i].second<<"\n";
        rn += event[i].second;
        if(rn>ng){
            ng = rn;
        }
    }
    rn = 0;
    for(int i=0; i<event.size(); i++){
        rn += event[i].second;
        if(rn==ng){
            br += (event[i+1].first-event[i].first);
            ///cout<<event[i+1].first<<" - "<<event[i].first<<"\n";
        }
    }
    //for(int i=0; i<20; i++){
    //    cout<<i<<": "<<a[i]<<", "<<ps[i]<<"\n";
   // }
    cout<<ng<<"\n"<<br;
    return 0;
}
/*
6
7 9
5 6
1 4
7 9
1 8
2 6
*/
