#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
const int N=2*1e5+5,inf=1e9+5;;
int n;
LL A,B=inf,_A,_B=inf,ans;
int in[N],ou[N],cnt;
struct card {LL val,bag;} b[N<<1];
bool cmp(card u,card v)
{
	return u.val<v.val;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld%lld",&b[i*2-1].val,&b[i*2].val);
		b[i*2-1].bag=b[2*i].bag=i;
		if(b[i*2-1].val>b[i*2].val) swap(b[i*2-1],b[i*2]);
		A=max(b[i*2].val,A),B=min(b[i*2].val,B);
		_A=max(b[i*2-1].val,_A),_B=min(b[i*2-1].val,_B);
	}
	ans=(A-B)*(_A-_B);
	sort(b+1,b+n+1,cmp);
	int l=2,r=1;
	while(r<n*2)
	{
		while(cnt<n && r<n*2-1) cnt+=(in[b[++r].bag]==0),++in[b[r].bag];
		if(cnt==n)
		{
			while(in[b[l].bag]==2) --in[b[l].bag],++ou[b[l--].bag];
			//cout<<l<<" "<<r<<endl;
			ans=min(ans,(b[r].val-b[l].val)*(A-_B));
		}
		if(ou[b[l].bag]==1) break;
		++l,++r;
	}
	printf("%lld",ans);
	return 0;
}