Duff is addicted to meat! Malek wants to keep her happy for *n* days. In order to be happy in *i*-th day, she needs to eat exactly *a*<sub class="lower-index">*i*</sub> kilograms of meat.

There is a big shop uptown and Malek wants to buy meat for her from there. In *i*-th day, they sell meat for *p*<sub class="lower-index">*i*</sub> dollars per kilogram. Malek knows all numbers *a*<sub class="lower-index">1</sub>, ..., *a*<sub class="lower-index">*n*</sub> and *p*<sub class="lower-index">1</sub>, ..., *p*<sub class="lower-index">*n*</sub>. In each day, he can buy arbitrary amount of meat, also he can keep some meat he has for the future.

Malek is a little tired from cooking meat, so he asked for your help. Help him to minimize the total money he spends to keep Duff happy for *n* days.
The first line of input contains integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>), the number of days.

In the next *n* lines, *i*-th line contains two integers *a*<sub class="lower-index">*i*</sub> and *p*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub>, *p*<sub class="lower-index">*i*</sub> ≤ 100), the amount of meat Duff needs and the cost of meat in that day.
/* AimanIskndr */
#include <bits/stdc++.h>
using namespace std;
    
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair <int, int> ii;
typedef vector<ii> vii;
typedef map <int, int> mii;

#define fori(I, n) for(int i = I; i < n; i++)
#define forN(n) for(int i = n; i >= 0; i--) //reverse for loop
#define forj(J, n) for(int j = J; j < n; j++)
#define all(x) (x).begin(), (x).end()
#define elif(args) else if(args)
#define yes cout << "YES" <<endl
#define no cout << "NO" << endl
#define nl cout << endl;
#define debug(var) cout << #var << ": " << var << endl;
#define WN fixed << setprecision(0) <<
#define _ <<' '<<

int main(){
    
    int n, mnP = 100, cd, tb = 0, bil = 0;
    cin >> n;

    int a[n], p[n];
    fori(0, n){
        cin >> a[i] >> p[i];
        if(p[i] < mnP) {cd = i; mnP = p[i];};
    }
    fori(cd, n) tb += a[i];
    bil = mnP * tb;
    
    fori(0, cd){
        tb = a[i];
        mnP = p[i];
        forj(i+1, cd){
            if(mnP <= p[j]) { tb += a[j]; i++;}
            else break;
        }
        bil += tb * mnP;
    }
    cout << bil << endl;
}