// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)

#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)

#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)

template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}

template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}

#define fi first

#define se second

#define mkr(a,b) make_pair(a,b)

inline int read()

{

	int sum=0,p=1;char ch=getchar();

	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();

	if(ch=='-')p=-1,ch=getchar();

	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();

	return sum*p;

}



#define pii pair<ll,ll>



const int maxn=4e5+20;



pii a[maxn];

int n;

int x[maxn],y[maxn];



inline void init()

{

	n=read();

	REP(i,1,n)x[i]=read(),y[i]=read(),a[i*2-1]=mkr(x[i],i),a[i*2]=mkr(y[i],i);

	REP(i,1,n)if(x[i]>y[i])swap(x[i],y[i]);

	sort(a+1,a+n*2+1);

}



ll Ans=1ll<<60;

int vis[maxn];



inline void doing()

{

	// 1

	if(a[1].se!=a[n*2].se)

	{

		memset(vis,0,sizeof(vis));

		ll L,R;

		vis[a[n*2].se]++;

		REP(i,1,n*2-1)

		{

			if(!vis[a[i].se])vis[a[i].se]++;

			else { L=i;break;}

		}

		memset(vis,0,sizeof(vis));

		vis[a[1].se]++;

		DREP(i,n*2,1)

		{

			if(!vis[a[i].se])vis[a[i].se]++;

			else {R=a[i].fi; break;}

 		}

		memset(vis,0,sizeof(vis));

		REP(i,2,L)

		{

			chkmin(Ans,1ll*(a[n*2].fi-a[1].fi)*(R-a[i].fi));

			chkmax(R,(ll)y[a[i].se]);

		}

		//chkmin(Ans,1ll*(a[n*2].fi-a[1].fi)*(R-L));

	}



	//2

	ll mn1=1ll<<60,mx1=0,mn2=1ll<<60,mx2=0;

	memset(vis,0,sizeof(vis));

	REP(i,1,n*2)

	{

		if(!vis[a[i].se])vis[a[i].se]++,chkmin(mn1,a[i].fi),chkmax(mx1,a[i].fi);

		else chkmin(mn2,a[i].fi),chkmax(mx2,a[i].fi);

	}

	chkmin(Ans,1ll*(mx2-mn2)*(mx1-mn1));

	printf("%lld\n",Ans);

	

}



int main()

{

	init();

	doing();

	return 0;

}




// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>



#define LL long long

#define RG register



using namespace std;

template<class T> inline void read(T &x) {

	x = 0; RG char c = getchar(); bool f = 0;

	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;

	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();

	x = f ? -x : x;

	return ;

}

template<class T> inline void write(T x) {

	if (!x) {putchar(48);return ;}

	if (x < 0) x = -x, putchar('-');

	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;

	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;

}

const int N = 2e5 + 10, inf = 1e9;

int n;

struct node {

	int x, y;

} a[N];

bool cmp(node a, node b) {

	return a.x < b.x;

}

int lmx1[N], rmx1[N], lmn1[N], rmn1[N];

int lmx2[N], rmx2[N], lmn2[N], rmn2[N];



int main() {

	//freopen(".in", "r", stdin);

	//freopen(".out", "w", stdout);

	read(n);

	for (int i = 1; i <= n; i++) {

		read(a[i].x); read(a[i].y);

		if (a[i].x > a[i].y) swap(a[i].x, a[i].y);

	}

	sort(a + 1, a + 1 + n, cmp);

	int Rmax = -inf, Rmin = inf, Lmax = -inf, Lmin = inf;

	for (int i = 1; i <= n; i++) {

		lmx1[i] = Lmax = max(Lmax, a[i].x); lmn1[i] = Lmin = min(Lmin, a[i].x);

		rmx1[i] = Rmax = max(Rmax, a[i].y); rmn1[i] = Rmin = min(Rmin, a[i].y);

	}

	Rmax = -inf, Rmin = inf, Lmax = -inf, Lmin = inf;

	for (int i = n; i >= 1; i--) {

		lmx2[i] = Lmax = max(Lmax, a[i].x); lmn2[i] = Lmin = min(Lmin, a[i].x);

		rmx2[i] = Rmax = max(Rmax, a[i].y); rmn2[i] = Rmin = min(Rmin, a[i].y);

	}

	LL ans = 1ll * (Rmax - Rmin) * (Lmax - Lmin);

	for (int i = 2; i <= n; i++) {

		Lmax = max(lmx2[i], rmx1[i - 1]); Lmin = min(lmn2[i], rmn1[i - 1]);

		Rmax = max(rmx2[i], lmx1[i - 1]); Rmin = min(rmn2[i], lmn1[i - 1]);

		ans = min(ans, 1ll * (Rmax - Rmin) * (Lmax - Lmin));

	}

	printf("%lld\n", ans);

	return 0;

}


// Fastest known solution for this problem: