#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  scanf("%d",&n);
  vector<int> a(n),b(n);
  REP(i,n) scanf("%d%d",&a[i],&b[i]);
  int cost = 0;
  while(a.size() != 1){
    int t;
    int c = 0;
    REP(i,a.size()-1){
      int tmp = b[i]*a[i+1];
      if(tmp > c){
	t = i;
	c = tmp;
      }
    }
    //printf("t=%d\n",t);
    cost += a[t]*b[t]*a[t+1]*b[t+1];
    a[t+1] = a[t];
    a.erase(a.begin() + t);
    b.erase(b.begin() + t);
  }
  printf("%d\n",cost);
  return 0;
}