#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,mini=1000,abpos,ipos,miniab=0,ans=0,a1,a2,b1,b2;

int main(){
    cin>>N;
    int a[N],b[N];
    rep(i,N){
        cin>>a[i]>>b[i];
        if(mini>a[i]){
            if(miniab<b[i]){
                mini=a[i];
                abpos=0;
                ipos=i;
                miniab=b[i];
            }
        }
        if(mini>b[i]){
            if(miniab<a[i]){
                mini=b[i];
                abpos=1;
                ipos=i;
                miniab=a[i];
            }
        }
    }
    if(abpos==0){
        a1=mini;
        b1=b[ipos];
        rep(i,N){
            if(i==ipos)continue;
            a2=a[i];
            b2=b[i];
            ans+=a1*b1*a2*b2;
            b1=b2;
        }
    }
    else{
        a2=a[ipos];
        b2=mini;
        rep(i,N){
            if(i==ipos)continue;
            a1=a[i];
            b1=b[i];
            ans+=a1*b1*a2*b2;
            a2=a1;
        }
    }
    out(ans);
}

