```
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>PII;
#define x first
#define y second
const int N=50010,INF=0x3f3f3f3f;
int n;
PII a[N];
int xs[N],ys[N];
unordered_map<int,int>mp1;
unordered_map<int,int>mp2;
int main(){
scanf("%d",&n);
int mx1=INF,mx2=1,my1=INF,my2=1;
for(int i=1;i<=n;++i){
int x,y;
scanf("%d%d",&x,&y);
xs[i]=x;
ys[i]=y;
a[i]={x,y};
mp1[x]++;
mp2[y]++;
}
sort(xs+1,xs+n+1);
sort(ys+1,ys+n+1);
long long ans=1e16;
for(int i=1;i<=n;++i){
int x=a[i].x,y=a[i].y;
int mx1=xs[1],mx2=xs[n],my1=ys[1],my2=ys[n];
if(x==xs[1]||x==xs[n]||y==ys[1]||y==ys[n]){
if(mp1[x]==1){
if(x==xs[1])mx1=xs[2];
else if(x==xs[n])mx2=xs[n-1];
}
if(mp2[y]==1){
if(y==ys[1])my1=ys[2];
else if(y==ys[n])my2=ys[n-1];
}
ans=min(ans,1LL*(mx2-mx1)*(my2-my1));
}
}
printf("%lld\n",ans);
return 0;
}
```