#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include <string.h>
using namespace std;
const int maxn=200005;
long long ans1,ans2=1e18,n,da,xiao,maxx,maxy,minx=1e9+10,miny=1e9+10,weizhiy,weizhix;
struct pai
{
	long long x,y;
} p[maxn];
int main()
{
	scanf("%lld",&n);
	if(n==1)
	{
		printf("0");
		return 0;
	}
	for(int i=1; i<=n; i++)
	{
		scanf("%lld%lld",&p[i].x,&p[i].y);
		if(p[i].x>p[i].y)
			swap(p[i].x,p[i].y);
		maxx=max(maxx,p[i].x);
		if(p[i].y>maxy)
		{
			weizhiy=i;
			maxy=p[i].y;
		}
		if(p[i].x<minx)
		{
			weizhix=i;
			minx=p[i].x;
		}
		miny=min(miny,p[i].y);
	}
	ans1=(maxy-miny)*(maxx-minx);
//	cout<<ans1<<endl;
	long long da=p[weizhix].y,xiao=p[weizhiy].x;
	if(da<xiao)
		swap(da,xiao);
	if(weizhix!=weizhiy)
		for(int i=1; i<=n; i++)
		{
			if(i==weizhix||i==weizhiy)
				continue;
			else if((xiao<=p[i].x&&p[i].x<=da)||(xiao<=p[i].y&&p[i].y<=da))
				continue;
			else if(p[i].x>da)
				da=p[i].x;
			else if(p[i].y<xiao)
				xiao=p[i].y;
			else if(xiao-p[i].x<p[i].y-da)
				xiao=p[i].x;
			else
				da=p[i].y;
		}
	ans2=(maxy-minx)*(da-xiao);
//	cout<<ans2<<endl;
	printf("%lld",min(ans1,ans2));
	return 0;
}