#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
vectorv1(n),v2(n);
for(int i=0;i<n;i++){
cin>>v1[i]>>v2[i];
}
int begin=0,end=n;
while(begin<end){
int i1=(begin+end)/2;
int i2=(2*n+1)/2-i1;
int min1=(i1==n)?INT_MAX:v1[i1];
int max1=(i1==0)?INT_MIN:v1[i1-1];
int min2=(i2==n)?INT_MAX:v2[i2];
int max2=(i2==0)?INT_MIN:v2[i2-1];
if(max1<=min2&&max2<=min1){
cout<< (max(max1,max2)+min(min1,min2))/2;
break;
}
else if(max1>min2)end=i1-1;
else begin=i1+1;
}
return 0;
}