/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class EBallColoring {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<P> v(N);
        int minVal = INF;
        int minIdx = -1;
        int maxVal = -INF;
        int maxIdx = -1;
        REP(i, N) {
            int x, y;
            cin >> x >> y;
            v[i] = {x, y};
            if (x < minVal || y < minVal) {
                minVal = min(x, y);
                minIdx = i;
            }
            if (x > maxVal || y > maxVal) {
                maxVal = max(x, y);
                maxIdx = i;
            }
        }

        int res = INF;

        // Rmax最大、 Bminが最小
        {
            set<int> R, B;
            REP(i, N) {
                int x, y;
                tie(x, y) = v[i];
                if (x > y) swap(x, y);
                R.insert(y);
                B.insert(x);
            }
            res = (*R.rbegin() - *R.begin()) * (*B.rbegin() - *B.begin());
        }

        // Rmax最大, Rmin最小
        {
            set<P> B;
            REP(i, N) {
                int x, y;
                tie(x, y) = v[i];
                if (x > y) swap(x, y);
                if (i == minIdx) {
                    B.insert({y, i});
                } else {
                    B.insert({x, i});
                }
            }
            auto minKv = *B.begin();
            auto maxKv = *B.rbegin();
            res = min(res, (maxVal - minVal) * (maxKv.first - minKv.first));

            set<int> used;
            used.insert(minIdx);
            used.insert(maxIdx);
            while (N--) {
                auto kv = *B.begin();
                if (used.count(kv.second)) continue;
                B.erase(B.begin());

                int x, y;
                tie(x, y) = v[kv.second];
                B.insert({max(x, y), kv.second});
                used.insert(kv.second);

                minKv = *B.begin();
                maxKv = *B.rbegin();
                res = min(res, (maxVal - minVal) * (maxKv.first - minKv.first));
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EBallColoring solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 22144