// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <cstring>

#include <cmath>

#include <cstdlib>

#define ll long long

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

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

using namespace std;

const int N = 2e5 + 9, inf = 0x3f3f3f3f;

int n, l, r, cnt, sum, minn1 = inf, minn2 = inf, maxx1, maxx2, vis[N];

struct node{

    int num, pl;

}s[N << 1];

bool cmp(node x, node y){

    return x.num == y.num ? x.pl < y.pl : x.num < y.num;

}

int main(){

    scanf("%d", &n);

    rep(i, 1, n) {

        int x, y; scanf("%d%d", &x, &y);

        if(x > y) swap(x, y);

        minn1 = min(minn1, x), minn2 = min(minn2, y), maxx1 = max(maxx1, x), maxx2 = max(maxx2, y);

        s[++cnt].pl = i, s[cnt].num = x, s[++cnt].pl = i, s[cnt].num = y;

    }

    sort(s + 1, s + 2 * n + 1, cmp);

    l = 1;

    rep(i, 1, 2 * n) {

        if(!vis[s[i].pl]) sum++;

        vis[s[i].pl]++;

        if(sum == n) { r = i; break; }

    }

    int ans = s[r].num - s[l].num;

    while(r < n * 2){

        if(vis[s[l].pl] == 1) sum--;

        vis[s[l].pl]--, l++;

        if(sum != n) rep(i, r + 1, 2 * n) {

            vis[s[i].pl]++;

            if(vis[s[i].pl] == 1) {

                sum++, r = i;

                break;

            }

        }

        if(sum != n) break;

        ans = min(ans, s[r].num - s[l].num);

        //cout << l << " " << ans << endl;

    }

    //cout << ans << endl;

    printf("%lld", min(1ll * ans * (maxx2 - minn1), 1ll * (maxx1 - minn1) * (maxx2 - minn2)));

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.328853797034729x):
#include <cstdio>

#include <algorithm>

#include <cstring>

#include <cctype>

using namespace std;



namespace zyt

{

	template<typename T>

	inline bool read(T &x)

	{

		char c;

		bool f = false;

		x = 0;

		do

			c = getchar();

		while (c != EOF && c != '-' && !isdigit(c));

		if (c == EOF)

			return false;

		if (c == '-')

			f = true, c = getchar();

		do

			x = x * 10 + c - '0', c = getchar();

		while (isdigit(c));

		if (f)

			x = -x;

		return true;

	}

	template<typename T>

	inline void write(T x)

	{

		static char buf[20];

		char *pos = buf;

		if (x < 0)

			putchar('-'), x = -x;

		do

			*pos++ = x % 10 + '0';

		while (x /= 10);

		while (pos > buf)

			putchar(*--pos);

	}

	typedef long long ll;

	typedef pair<int, int> pii;

	const int N = 2e5 + 10;

	int n, sufmx[N], sufmn[N];

	pii arr[N];

	int work()

	{

		read(n);

		int mx = 0, mn = 1e9;

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

		{

			read(arr[i].first), read(arr[i].second);

			if (arr[i].first > arr[i].second)

				swap(arr[i].first, arr[i].second);

			mx = max(mx, arr[i].second), mn = min(mn, arr[i].second);

		}

		sort(arr + 1, arr + n + 1);

		ll ans = ll(arr[n].first - arr[1].first) * (mx - mn), k = mx - arr[1].first;

		mn = 1e9, mx = 0;

		sufmx[n + 1] = 0, sufmn[n + 1] = 1e9;

		for (int i = n; i > 0; i--)

			sufmx[i] = max(sufmx[i + 1], arr[i].first), sufmn[i] = min(sufmn[i + 1], arr[i].first);

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

		{

			mn = min(mn, arr[i].second), mx = max(mx, arr[i].second);

			ans = min(ans, k * (max(sufmx[i + 1], mx) - min(sufmn[i + 1], mn)));

		}

		write(ans);

		return 0;

	}

}

int main()

{

	return zyt::work();

}