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_{i} kilograms of meat. [Image] 

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_{i} dollars per kilogram. Malek knows all numbers a_1, ..., a_{n} and p_1, ..., p_{n}. 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. 


-----Input-----

The first line of input contains integer n (1 ≤ n ≤ 10^5), the number of days.

In the next n lines, i-th line contains two integers a_{i} and p_{i} (1 ≤ a_{i}, p_{i} ≤ 100), the amount of meat Duff needs and the cost of meat in that day.


-----Output-----

Print the minimum money needed to keep Duff happy for n days, in one line.


-----Examples-----
Input
3
1 3
2 2
3 1

Output
10

Input
3
1 3
2 1
3 2

Output
8



-----Note-----

In the first sample case: An optimal way would be to buy 1 kg on the first day, 2 kg on the second day and 3 kg on the third day.

In the second sample case: An optimal way would be to buy 1 kg on the first day and 5 kg (needed meat for the second and third day) on the second day.

Difficulty: interview

Starter code:

Solutions:
n = int(input())

bestP = 10**9
sol = 0
for i in range(0, n):
    a, p = list(map(int, input().split()))

    bestP = min(bestP, p)
    sol += a * bestP

print(sol)


n = int(input())
mini = 10 ** 9 + 7
sum = 0
for i in range(n):
    a, p = list(map(int, input().split()))
    mini = min(mini, p)
    sum += mini * a
print(sum)
    


n = int(input())
ans = 0
minp = 10**10
for i in range(n):
    a, p = list(map(int, input().split()))
    if p < minp:
        minp = p
    ans += a*minp
print(ans)


ans, cur = 0, 1 << 179
for i in range(int(input())):
    a, p = list(map(int, input().split()))
    cur = min(cur, p)
    ans += a * cur
print(ans)


n = int(input())
s = 0
mi = 1e9
for i in range(n):
    a, p = map(int, input().split())
    mi = min(mi, p)
    s += a * mi
print(s)

n=int(input())
p=[list(map(int,input().split())) for i in range(n)]
m=1000
s=0
for x in p:
   if m>x[1]: m=x[1]
   s+=x[0]*m
print(s)

n = int(input())
x = []
y = []
m = 101
r = 0
for i in range(n):
    a,b = list(map(int,input().split()))
    if b<m:
        m = b
    r = r + a*m

print (r)


n = int(input())
a = []
p = []
prev = 1e9
ans = 0
for i in range(n):
    x, y = map(int, input().split())
    if y < prev:
        prev = y
    ans += x * prev
print(ans)

import sys

n = int(input())
menor = 10000000
sum = 0
for i in range(n):
    line = input()
    v = [int(x) for x in line.split()]
    if(v[1] < menor):
        menor = v[1]
    sum += menor*v[0]
print(sum)

n = int(input())

pmin = 1000

sum = 0

for i in range(n):
    a, p = map(int, input().split())
    if p < pmin:
        pmin = p
    sum += a * pmin
    
print(sum)

n = int(input())
price = [0 for i in range(n)]
req = [0 for i in range(n)]
for i in range(n):
    req[i], price[i] = map(int, input().split())

cur_min = price[0]
ans = 0
for i in range(n):
    cur_min = min([price[i], cur_min])
    ans += cur_min*req[i]
print(ans)

n = int(input())
a, p = list(map(int, input().split()))
minpref = p
ans = a * p
for i in range(n - 1):
    a, p = list(map(int, input().split()))
    minpref = min(minpref, p)
    ans += a * minpref
print(ans)
    


import sys


#sys.stdin = open("input.txt")
#sys.stdout = open("output.txt", "w")

n = int(input())
a = []
p = []
for i in range(n):
	x, y = [int(i) for i in input().split()]
	a.append(x)
	p.append(y)

ans, price = 0, p[0]
for i in range(n):
	price = min(price, p[i])
	ans += a[i] * price

print(ans)



n = int(input())
minn = 101
ans = 0
for i in range(n):
    a, p = input().split()
    a = int(a)
    p = int(p)
    if p < minn:
        minn = p
    ans += minn*a
print(ans)

def __starting_point():
    n = int(input())
    prices = []
    needs = []

    for i in range(n):
        n, p = map(int, input().split())
        prices.append(p)
        needs.append(n)

    total = 0
    curr = needs[0]
    curr_p = prices[0]

    for i in range(1, len(prices)):
        if prices[i] < curr_p:
            total += curr_p * curr
            curr = 0
            curr_p = prices[i]

        curr += needs[i]

    total += curr_p * curr

    print(total)
__starting_point()

n = int(input())
a = [0] * n
p = [0] * n
for i in range(n):
    a[i], p[i] = map(int, input().split())
minP = [p[0]] * n
for i in range(1, n):
    minP[i] = min(minP[i - 1], p[i])
ans = 0
for i in range(n):
    ans += a[i] * minP[i]
print(ans)

n = int(input())

a = []
p = []
dp = []

for i in range(n):
    cur1, cur2 = map(int, input().split())
    a.append(cur1)
    p.append(cur2)

dp.append(p[0])
sum = p[0] * a[0]

for i in range(1, n):
    if p[i] >= dp[-1]:
        dp.append(dp[-1])
    else:
        dp.append(p[i])
    sum += dp[-1] * a[i]

print(sum)

n = int(input())
ans = 0
curMin = 101
for i in range(n):
    a, p = list(map(int,input().strip().split()))
    curMin = min(p, curMin)
    ans += a*curMin

print(ans)


n = int(input())
meat = [0] * n
price = [0] * n
for i in range(n):
    meat[i], price[i] = list(map(int, input().split()))
min_price = price[0]
ans = 0
for i in range(n):
    min_price = min(min_price, price[i])
    ans += min_price * meat[i]
print(ans)


n = int(input())
a = []
p = []

for i in range(n):
    ai, pi = list(map(int, input().split()))
    a.append(ai)
    p.append(pi)

cost = 0
meat = 0
for i in range(n):
    if meat == 0:
        cost += p[i] * a[i]
        meat += a[i]
        for j in range(i+1, n):
            if p[j] < p[i]:
                break
            cost += p[i] * a[j]
            meat += a[j]

    meat -= a[i]

print(cost)



from itertools import islice

n = int(input())
a = [0] * n
p = [0] * n
for i in range(n):
    a[i], p[i] = list(map(int, input().split()))
prev_price = p[0]
result = 0
s = a[0]
for i in range(1, n):
    if p[i] < prev_price:
        result += prev_price * s
        s = a[i]
        prev_price = p[i]
    else:
        s += a[i]
print(result + prev_price * s)


n = int(input())

curr_p = 1000
curr_meat = 0
coast = 0

for i in range(n):
    a, p = map(int, input().split())
    if p < curr_p:
        coast += curr_p * curr_meat
        curr_p = p
        curr_meat = a
    else:
        curr_meat += a

coast += curr_p * curr_meat
print(coast)

n = int(input())
a, p = [], []
for _ in range(n):
    x,y = map(int, input().split())
    a.append(x)
    p.append(y)
    
cur_min = float('inf')
cost = 0

for i in range(n):
    cur_min = min(cur_min, p[i])
    cost += cur_min * a[i]
print(cost)

n = int(input())
ans = 0
money = float('inf')
for i in range(n):
    a, b = map(int, input().split())
    money = min(money, b)
    ans += money * a
print(ans)

# import sys
# sys.stdin = open('cf588a.in')

n = int(input())
vals = [tuple(int(v) for v in input().split()) for _ in range(n)]

other = [(p, i) for i, (a, p) in enumerate(vals)]
other.sort()

last = n
ans = 0

for p, i in other:
	if i > last:
		continue
	ans += sum(a for a, pp in vals[i:last]) * p
	last = i
	if last == 0:
		break

print(ans)