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.
import time

#t0 = time.time()
n = int(input())
s = []
a = []
for i in range(n):
    a = list(map(int,input().split()))
    a.append(i)
    s.append(a)
#t1 =time.time()

def getMin(end,s):#超时emmm
    if end==0:
        return 0
    totalprice = 0
    minprice = [100,-1]
    day = end-len(s)-1
    while -day<=len(s):
        if s[day][1]<=minprice[0]:
            minprice[0] = s[day][1]
            minprice[1] = day
        day -= 1
    endnx = len(s)+minprice[1]
    #print('place:',minprice[1],'end:',end)
    while minprice[1]<end-len(s):
        totalprice += s[minprice[1]][0]*minprice[0]
        minprice[1] += 1
    #print('total:',totalprice)
    return totalprice + getMin(endnx,s)

def getMinFast(s):
    minlist = [s[0]]
    day = 1
    while day<len(s):
        if s[day][1]<minlist[-1][1]:
            minlist.append(s[day])
        day += 1
    minlist[-1][-1] = len(s)-1
    lastday = 0
    totalprice = 0
    for m in minlist:
        while lastday<=m[2]:
            totalprice += m[1]*s[lastday][0]
            lastday += 1
    return totalprice

#t3 = time.time()
print(getMinFast(s))
#t4 = time.time()
#print(getMin(len(s),s))
#t5 = time.time()
#print('read:',t1-t0,'\nnormal:',t5-t4,'\nfast(nohazu):',t4-t3)