import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto X = new long[](N);
    auto Y = new long[](N);
    foreach (i; 0..N) {
        auto s = readln.split.map!(to!long);
        X[i] = s[0];
        Y[i] = s[1];
    }

    long max_v = max(X.reduce!max, Y.reduce!max);
    long min_v = min(X.reduce!min, Y.reduce!min);
    long b_max = -1;
    long b_min = long.max;
    foreach (i; 0..N) {
        b_max = max(b_max, min(X[i], Y[i]));
        b_min = min(b_min, max(X[i], Y[i]));
    }

    long ans;
    long ans1 = (max_v - min_v) * (b_max - b_min);
    long ans2 = (max_v - b_min) * (b_max - min_v);
    if (ans1 < 0) ans = ans2;
    else if (ans2 < 0) ans = ans1;
    else ans = min(ans1, ans2);

    foreach (i; 0..N) {
        auto mx = max(X[i], Y[i]);
        auto mn = min(X[i], Y[i]);
        if (mx == max_v && mn == min_v) {
            writeln(ans2);
            return;
        }
    }

    ans.writeln;
}
