import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=rdsp;foreach(ref j;v.tupleof)pick(r,j);}}

void main()
{
  int n; readV(n);
  struct P { int x, y; }
  P[] p; readS(n, p);

  foreach (ref pi; p)
    if (pi.x < pi.y) swap(pi.x, pi.y);

  auto xa = p.map!"a.x".reduce!max;
  auto xi = p.map!"a.x".reduce!min;
  auto ya = p.map!"a.y".reduce!max;
  auto yi = p.map!"a.y".reduce!min;
  auto ans = (xa-xi).to!long*(ya-yi);

  p.sort!"a.y < b.y";
  auto y = p.map!"a.y".array;
  auto sta = new SegmentTree!(int, max)(y);
  auto sti = new SegmentTree!(int, min)(y, int.max);

  auto mi = ya-yi;
  foreach (i, pi; p) {
    sta[i] = pi.x;
    sti[i] = pi.x;
    auto mi2 = sta[0..$]-sti[0..$];
    if (mi2 > mi) break;
    mi = mi2;
  }

  ans = min(ans, (xa-yi).to!long*mi);
  writeln(ans);
}

class SegmentTree(T, alias pred = "a + b")
{
  import core.bitop, std.functional;
  alias predFun = binaryFun!pred;

  const size_t n, an;
  T[] buf;
  T unit;

  this(size_t n, T unit = T.init)
  {
    this.n = n;
    this.unit = unit;
    an = n == 1 ? 1 : (1 << ((n-1).bsr + 1));
    buf = new T[](an*2);
    if (T.init != unit) buf[] = unit;
  }

  this(T[] init, T unit = T.init)
  {
    this(init.length, unit);
    buf[an..an+n][] = init[];
    foreach_reverse (i; 1..an)
      buf[i] = predFun(buf[i*2], buf[i*2+1]);
  }

  void opIndexAssign(T val, size_t i)
  {
    buf[i += an] = val;
    while (i /= 2)
      buf[i] = predFun(buf[i*2], buf[i*2+1]);
  }

  pure T opSlice(size_t l, size_t r)
  {
    l += an; r += an;
    T r1 = unit, r2 = unit;
    while (l != r) {
      if (l % 2) r1 = predFun(r1, buf[l++]);
      if (r % 2) r2 = predFun(buf[--r], r2);
      l /= 2; r /= 2;
    }
    return predFun(r1, r2);
  }

  pure T opIndex(size_t i) { return buf[i+an]; }
  pure size_t opDollar() { return n; }
}
