// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

struct SegmentTree {
  private:
    int n;
    vector<int> node;

public:
  SegmentTree(vector<int> v) {
    int sz = (int)v.size();
    n = 1; while(n < sz) n *= 2;
    node.resize(2*n-1);

    REP(i,sz) node[i+n-1] = v[i];
    RREP(i,n-1) node[i] = min(node[i*2+1],node[i*2+2]); //最大値ならmax
  }

  // 0_indexedでk番目の要素をaに変更
  void update(int k, int a){
    k += n-1;
    node[k] = a;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = min(node[k*2+1],node[k*2+2]); //最大値ならmax
    }
  }

  // 半開区間[l,r)から、[a,b)に対するクエリ。
  int query(int a, int b, int k=0, int l=0, int r=-1){
    if(r < 0) r = n;
    if(r <= a || b <= l) return INF; // 最大値なら-INF
    if(a <= l && r <= b) return node[k];
    else{
      int vl = query(a,b,k*2+1,l,(l+r)/2);
      int vr = query(a,b,k*2+2,(l+r)/2,r);
      return min(vl,vr); //最大値ならmax
    }
  }
};

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);  
  //問題文を読む時間をケチらない！！

  int n;
  cin >> n;

  vector<int> x(n),y(n);
  int mx = 0, mn = INF, mx_id, mn_id;
  REP(i,n){
    cin >> x[i] >> y[i];
    if(x[i] > y[i]) swap(x[i],y[i]);
    if(mx < y[i]) mx = y[i],mx_id = i;
    if(mn > x[i]) mn = x[i],mn_id = i;
  }

  //minとmaxが別の色
  int mx_x = 0, mx_y = 0, mn_x = INF, mn_y = INF;
  REP(i,n){
    mn_x = min(mn_x,x[i]);
    mn_y = min(mn_y,y[i]);
    mx_x = max(mx_x,x[i]);
    mx_y = max(mx_y,y[i]);
  }
  int ans1 = (mx_x - mn_x)*(mx_y - mn_y);

  //minとmaxが同色
  int cur_mx = max(x[mx_id],y[mn_id]), cur_mn = min(x[mx_id],y[mn_id]);
  vector<int> id;
  REP(i,n){
    if(range(x[i],cur_mn,cur_mx+1) || range(y[i],cur_mn,cur_mx+1)) continue;
    if((x[i] < cur_mn) != (y[i] < cur_mn)) id.push_back(i);
    else if(x[i] < cur_mn) cur_mn = max(x[i],y[i]);
    else cur_mx = min(x[i],y[i]);
  }

  vector<P> tmp;
  REP(i,id.size()){
    if(range(x[id[i]],cur_mn,cur_mx+1) || range(y[id[i]],cur_mn,cur_mx+1)) continue;
    tmp.push_back(P(y[id[i]],x[id[i]]));
  }

  sort(tmp.begin(),tmp.end());
  int m = tmp.size();
  int ans2 = INF;
  if(m){
    vector<int> v(m);
    REP(i,m) v[i] = tmp[i].sc;
    SegmentTree seg(v);
    int len = cur_mx-seg.query(0,m);
    REP(i,m-1){
      len = min(len,tmp[i].fs-seg.query(i+1,m));
    }
    len = min(len,tmp[m-1].fs-cur_mn);
    ans2 = (mx-mn) * len;
  }
  else ans2 = (mx-mn) * (cur_mx-cur_mn);

  cout << min(ans1,ans2) << endl;

  return 0;
}

Measured memory_bytes: 3456