"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var x = [];
  for(var i = 0; i < n; i++){
    var u = next(), v = next();
    if(v < u){var temp = u; u = v; v = temp;}
    x.push([u,v]);
  }
  x.sort((a,b)=>b[0]>a[0]?1:b[0]<a[0]?-1:a[1]-b[1]);
  var rx = 0, rn = x[n-1][0], bx = 0, bn = 1e9;
  for(var i = 0; i < n; i++){
    if(rx < x[i][0])rx = x[i][0];
    if(bx < x[i][1])bx = x[i][1];
    if(bn > x[i][1])bn = x[i][1];
  }
  var ans = solve(rx,rn,bx,bn);
  var r = x[0][0];
  var [aa,b] = x.pop();
  x.sort((a,b)=>a[1]-b[1]);
  while(x.length){
    var [u,v] = x.pop();
    if(b >= v)break;
    rx = Math.max(rx,v);
    bn = Math.min(bn,u);
    if(x.length)bx = Math.max(b,x[x.length-1][1],r);
    var t = solve(rx,rn,bx,bn);
    if(ans > t)ans = t;
  }
  return ans;
}
function solve(a,b,c,d){
  return BigInt(a-b) * BigInt(c-d);
}