#include<bits/stdc++.h>
using namespace std;
priority_queue<pair<int ,char>> pq;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n ;
    cin>>n;
    int x, y, endM = 0;
    for(int i = 1; i <= n ; i++){
        cin>>x>>y;
        pq.push({-x,'o'});
        pq.push({-y,'c'});
    }
    int Op = 0,curr,prevO = 0,prevM = 0;
    int mxS = 0 , d = 0;
    while(!pq.empty()){
        prevO = Op;
        curr = -pq.top().first;
        while(!pq.empty() && -pq.top().first == curr){
            if(pq.top().second == 'o'){
                Op++;
            }else{
                Op--;
            }

            pq.pop();
        }
        if(mxS<min(prevO,Op)){
            mxS = min(prevO,Op);
            d = 1 ;
        }
        if(curr - prevM >= 2 && prevO > Op && prevO > mxS){
            mxS = prevO;
            d = curr-prevM;
        }
        if(Op == mxS){
            d+=curr-prevM;
        }
        prevM = curr;
    }
    cout<<mxS<<endl<<d;
    return 0;

}
