#include <iostream>
//#include <fstream>
#include <vector>
#include <deque>
#include <algorithm>
#include <climits>
#include <map>
#define ll long long
using namespace std;
//ifstream cin ("input.in");
//ofstream cout ("output.out");
ll n,m,i,j,a,b,len,start,nr,pos,mini=LLONG_MAX,curr;
struct adat
{
ll value;
bool st;
};
struct element
{
ll start=0,stop=0;
};
bool compare (const adat& a, const adat &b)
{
if (a.value<b.value) return true;
if (a.value==b.value) return a.st;
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>n;
// vector <adat> x(2*n+1);
map<ll,element> x;
for (i=1;i<=n;++i)
{
cin>>a>>b;
x[a].start++;
x[b].stop++;
/*x[2*i-1].value=a;
x[2*i-1].st=true;
x[2*i].value=b;
x[2*i].st=false;*/
}
deque <ll> v;
//v.push_back(x.begin()->first);
a=0;
ll half=(n+1)/2;
for (auto &e:x)
{
v.push_back(e.first);
a+=e.second.start;
while (!v.empty()&&a>half)
{
a-=x[v[0]].stop;
v.pop_front();
}
while (a==half&&!v.empty())
{
if (x[v[0]].stop) break;
else v.pop_front();
}
if (a>=half&&e.first-v[0]+1<mini)
{
mini=e.first-v[0]+1;
pos=e.first;
}
//a-=e.second.stop;
}
//sort (x.begin()+1, x.end(),compare);
/*start=1;
a=1;
curr=2;
ll middle=(n+1)/2;
while (a<middle&&curr<=2*n)
{
if (x[curr].st) a++;
curr++;
}
pos=1;
mini=x[curr-1].value-x[start].value;
while (curr<=2*n)
{
if (x[curr].st) a++;
while (start<=curr&&a>middle)
{
if (!x[start].st) a--;
start++;
}
while (a==middle)
{
if (!x[start].st) break;
start++;
}
if (a>=middle&&x[curr].value-x[start].value+1<mini)
{
mini=x[curr].value-x[start].value+1;
pos=x[start].value;
}
curr++;
}*/
cout<<mini<<"\n"<<pos-mini+1<<" "<<pos;
}