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: EASY
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
n = int(input())
a = []
p = []
for i in range(n):
	day = [int(x) for x in input().split()]
	a.append(day[0])
	p.append(day[1])
s = 0
i = 0
price = p[0]
while i <= n - 1:
	if p[i] >= price:
		s = s + a[i] * price
		i = i + 1
	else:
		price = p[i]
		s = s + a[i] * price
		i = i + 1
print(s)


size = input()
meat = []
price = []
bestPrice = 1001
totalCost = 0
for i in range(int(size)):
	(m, p) = map(int, input().split())
	bestPrice = min(bestPrice, p)
	totalCost += m * bestPrice
print(totalCost)


import itertools, functools, math

def solve():
	n = int(input())
	total = 0
	min_cost = 9999999999
	for _ in range(n):
		(a, p) = map(int, input().split())
		min_cost = min(min_cost, p)
		total += min_cost * a
	return total
print(solve())


n = int(input())
minprice = 10 ** 9
ans = 0
while n:
	n -= 1
	(a, b) = map(int, input().split())
	minprice = min(minprice, b)
	ans += a * minprice
print(ans)


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


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)


def buy_meat(days):
	total = 0
	best_cost = 100
	for day in range(days):
		(amount, cost) = map(int, input().split())
		if cost < best_cost:
			best_cost = cost
			total += best_cost * amount
		else:
			total += best_cost * amount
	return total
print(buy_meat(int(input())))


from sys import stdin, stdout
input = stdin.readline
n = int(input())
ap = [list(map(int, input().split())) for i in range(n)]
ap.append([0, -float('inf')])
ans = 0
i = 0
while i < n:
	rps = ap[i][1]
	ans += ap[i][0] * rps
	while rps < ap[i + 1][1]:
		ans += ap[i + 1][0] * rps
		i += 1
	i += 1
stdout.write(str(ans))


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
nb_days = read_int()
min_price = max_val
spent = 0
for _ in range(nb_days):
	(need, price) = read_ints()
	min_price = min(min_price, price)
	spent += min_price * need
print(spent)


n = int(input())
a = list()
p = list()
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	p.append(y)
c = p[0] * a[0]
low = p[0]
for i in range(1, n):
	if p[i] < low:
		low = p[i]
		c += low * a[i]
	else:
		c += low * a[i]
print(c)


n = int(input())
(res, x) = (0, 2000000000.0)
for i in range(n):
	(a, b) = map(int, input().split())
	if b < x:
		x = b
	res = res + a * x
print(res)


t = int(input())
lst = []
lst1 = []
for i in range(t):
	(a, p) = map(int, input().split())
	lst.append(a)
	lst1.append(p)
d = lst[0] * lst1[0]
r = 0
for i in range(1, len(lst)):
	if lst1[i - 1] < lst1[i]:
		d += lst[i] * lst1[i - 1]
		lst1[i] = lst1[i - 1]
	else:
		d += lst[i] * lst1[i]
print(d)


n = int(input())
minp = 100000000
res = 0
for i in range(0, n):
	(a, p) = map(int, input().split())
	minp = min(p, minp)
	res = res + a * minp
print(res)


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


t = 123
r = 0
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	t = min(t, b)
	r += a * t
print(r)


t = int(input())
meat = []
money = []
while t > 0:
	num = [int(i) for i in input().split()]
	a = num[0]
	b = num[1]
	meat.append(a)
	money.append(b)
	t = t - 1
tot = 0
min = money[0]
for i in range(len(meat)):
	if money[i] < min:
		min = money[i]
	tot = tot + min * meat[i]
print(tot)


mn = 10 ** 9
res = 0
for n in range(int(input())):
	(a, b) = map(int, input().split())
	if b <= mn:
		mn = b
	res += a * mn
print(res)


n = int(input())
amount = []
money = []
for i in range(n):
	(a, b) = map(int, input().split())
	amount.append(a)
	money.append(b)
cost = amount[0] * money[0]
small = money[0]
for i in range(1, n):
	if money[i] >= small:
		cost += small * amount[i]
	else:
		small = money[i]
		cost += small * amount[i]
print(cost)


def main():
	res = asum = 0
	pmin = 100
	for _ in range(int(input())):
		(a, p) = map(int, input().split())
		if pmin > p:
			res += asum * pmin
			(asum, pmin) = (a, p)
		else:
			asum += a
	print(res + asum * pmin)
main()


n = int(input())
(a, p) = ([], [])
for i in range(n):
	(x, z) = map(int, input().split())
	a.append(x)
	p.append(z)
s = 0
i = 0
while i < n:
	tmp = 1
	s += p[i] * a[i]
	for j in range(i, n - 1):
		if p[i] > p[j + 1]:
			break
		s += p[i] * a[j + 1]
		tmp += 1
	i += tmp
print(s)


__author__ = 'JohnHook'
n = int(input())
mn = 1000
ans = 0
for i in range(n):
	(a, b) = list(map(int, input().split()))
	mn = min(mn, b)
	ans += a * mn
print(ans)


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


n = int(input())
m = 123
s = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	m = min(m, b)
	s = s + a * m
print(s)


(cost, prev) = (0, 0)
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if prev != 0 and prev < b:
		cost += prev * a
	else:
		cost += a * b
		prev = b
print(cost)


import copy

class Cont:
	pass
n = int(input())
byCost = []
for i in range(n):
	(a, b) = [int(x) for x in input().split(' ')]
	o = Cont()
	o.eat = a
	o.price = b
	byCost.append(o)
c = 0
for i in range(len(byCost)):
	j = len(byCost) - i - 1
	c += byCost[j].eat
	byCost[j].cummulative = c
byCost.sort(key=lambda x: x.price)
cost = 0
eaten = 0
for (i, e) in enumerate(byCost):
	if eaten < e.cummulative:
		n = e.cummulative - eaten
		cost += n * e.price
		eaten += n
print(cost)


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
m = l[0][1]
s = m * l[0][0]
for i in range(1, n):
	if l[i][1] < m:
		m = l[i][1]
	s += m * l[i][0]
print(s)


money = 0
price = 101
n = int(input())
while n > 0:
	x = input()
	(a, p) = x.split(' ')
	a = int(a)
	p = int(p)
	if price > p:
		price = p
	money += price * a
	n -= 1
print(money)


min = 101
ans = 0
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	if y < min:
		min = y
	ans += x * min
print(ans)


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


n = int(input())
m = 100
sum = 0
while n:
	(a, p) = map(int, input().split())
	if m > p:
		m = p
	sum = sum + a * m
	n = n - 1
print(sum)


n = int(input())
s = 0
dayskg = 0
cenamin = 100
for i in range(n):
	(kg, cena) = map(int, input().split())
	if cena < cenamin:
		cenamin = cena
	s += kg * cenamin
print(s)


n = int(input())
l = []
for i in range(n):
	l.append(input().split())
	l[i][0] = int(l[i][0])
	l[i][1] = int(l[i][1])
s = l[0][0] * l[0][1]
pricemin = l[0][1]
for i in range(1, n):
	pricemin = min(pricemin, l[i][1])
	s += pricemin * l[i][0]
print(s)


n = int(input())
fudge = n * [None]
cost = n * [None]
for i in range(n):
	(fudge[i], cost[i]) = map(int, input().split())
unit_cost = cost[0]
needed = sum(fudge)
result = needed * unit_cost
needed -= fudge[0]
for i in range(1, n):
	if cost[i] < unit_cost:
		result -= needed * (unit_cost - cost[i])
		unit_cost = cost[i]
	needed -= fudge[i]
print(result)


aa = int(input())
a = 0
b = 10000000
total = 0
for x in range(aa):
	t = input()
	t = t.split()
	if int(t[1]) < b:
		total += int(t[0]) * int(t[1])
		b = int(t[1])
	else:
		total += int(t[0]) * b
print(total)


n = int(input())
total = 0
curMin = 999
for _ in range(n):
	(a, p) = list(map(int, input().rstrip().split(' ')))
	if p < curMin:
		curMin = p
	total += a * curMin
print(total)


from collections import deque, Counter
import array
from itertools import combinations, permutations
from math import sqrt
import unittest

def read_int():
	return int(input().strip())

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
n = read_int()
A = []
P = []
for _ in range(n):
	(a, p) = read_int_array()
	A += [a]
	P += [p]
spent = P[0] * A[0]
min_p = P[0]
for i in range(1, n):
	if P[i] < min_p:
		min_p = P[i]
	spent += A[i] * min_p
print(spent)


n = int(input())
s = 0
price = 100 ** 2
for i in range(n):
	(kg, p) = map(int, input().split())
	price = min(price, p)
	s += kg * price
print(s)


number = int(input())
answer = 0
lim = 100
for i in range(0, number):
	(amount, price) = map(int, input().split())
	if price > lim:
		answer += amount * lim
	else:
		answer += amount * price
		lim = price
print(answer)


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) = ([], [])
for i in range(n):
	(a, p) = map(int, input().split())
	A.append(a)
	P.append(p)
temp_min_price = max(P)
min_price = min(P)
money = 0
for i in range(len(P)):
	if P[i] == min_price:
		money += sum(A[i:]) * min_price
		break
	if P[i] < temp_min_price:
		temp_min_price = P[i]
	money += A[i] * temp_min_price
print(money)


n = int(input())
x = []
for _ in range(n):
	(a, p) = map(int, input().split())
	x.append([a, p])
ind = 0
ans = 0
while ind < n:
	ans += x[ind][0] * x[ind][1]
	price = x[ind][1]
	ind += 1
	while ind < n and x[ind][1] >= price:
		ans += x[ind][0] * price
		ind += 1
print(ans)


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)


from sys import stdin

def main():
	days = int(stdin.readline())
	price = float('inf')
	ans = 0
	for d in range(days):
		(di, pi) = [int(x) for x in stdin.readline().strip().split()]
		price = min(price, pi)
		ans += price * di
	print(ans)
main()


__author__ = 'yarsanich'
n = int(input())
q = 10 ** 9
ans = 0
for i in range(n):
	(x, y) = map(int, input().split())
	q = min(q, y)
	ans = ans + x * q
print(ans)


n = int(input())
total = 0
bestp = 9999999999999999
for _ in range(n):
	(newa, newp) = map(int, input().split())
	bestp = min(newp, bestp)
	total += newa * bestp
print(total)


n = int(input())
l = []
p = []
d = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append([a, b])
	p.append(b)
	d.append(a)
day = 0
i = day
price = 1
cost = 0
while day < n:
	while i < n:
		if l[day][price] <= l[i][price]:
			cost += l[day][price] * l[i][0]
			i += 1
		else:
			day = i
	day += 1
print(cost)


n = int(input())
l = []
cost = 0
for f in range(n):
	(a, p) = map(int, input().split())
	l.append((a, p))
min = 101
for (a, p) in l:
	if min > p:
		min = p
	cost = cost + a * min
print(cost)


n = int(input())
price = 0
cost = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if i == 0:
		price = p
	else:
		price = min(price, p)
	cost += a * price
print(cost)


n = int(input())
ans = 0
minimum = 10000
for i in range(n):
	(a, p) = map(int, input().split())
	minimum = min(minimum, p)
	ans += a * minimum
print(ans)


n = int(input())
lp = 100000
cost = 0
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	lp = min(lp, b)
	cost += a * lp
print(cost)


n = int(input())
mini = 100
total = 0
for i in range(n):
	a_p = list(map(int, input().split(' ')))
	(a, p) = a_p
	mini = min(mini, p)
	total += a * mini
print(total)


n = int(input())
ans = 0
m = 10 ** 9
for _ in range(n):
	(d, c) = list(map(int, input().split()))
	m = min(m, c)
	ans += d * m
print(ans)


n = int(input())
min_price = 101
total = 0
for _ in range(n):
	(day_amount, price) = map(int, input().split())
	if price < min_price:
		min_price = price
	total += day_amount * min_price
print(total)


n = int(input())
a = []
cost = 0
b = []
for i in range(n):
	(z, y) = [int(x) for x in input().split()]
	a.append(z)
	b.append(y)
cost += a[0] * b[0]
k = b[0]
for i in range(1, n):
	if b[i] <= k:
		k = b[i]
	cost += a[i] * k
print(cost)


__author__ = 'cmashinho'
n = int(input())
needMeat = []
meatPrice = []
for _ in range(n):
	(a, b) = map(int, input().split())
	needMeat.append(a)
	meatPrice.append(b)
answer = 0
minPrice = min(meatPrice)
i = 0
while i < n:
	it = False
	if meatPrice[i] == minPrice:
		for j in range(i, n):
			answer += needMeat[j] * minPrice
		break
	else:
		for j in range(i, n):
			if meatPrice[i] <= meatPrice[j]:
				answer += needMeat[j] * meatPrice[i]
			else:
				it = True
				i = j
				break
	if it:
		continue
	else:
		i += 1
print(answer)


n = int(input())
(res, p) = (0, 101)
for i in range(n):
	(a, b) = map(int, input().split())
	if p > b:
		p = b
	res += a * p
print(res)


from sys import stdin
n = int(stdin.readline())
res = 0
price = float('inf')
for _ in range(n):
	(x, y) = list(map(int, stdin.readline().split()))
	if y < price:
		price = y
	res += price * x
print(res)


pq = []
for _ in range(int(input())):
	(quantity, price) = map(int, input().split())
	pq.append((quantity, price))
(ans, v, w) = (0, pq[0][1], pq[0][0])
for (i, j) in enumerate(pq):
	if i == 0:
		continue
	if v <= j[1]:
		w += j[0]
	else:
		ans += w * v
		w = j[0]
		v = j[1]
print(ans + w * v)


n = int(input())
(min, sum) = (101, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	if b < min:
		sum += b * a
		min = b
	else:
		sum += min * a
print(sum)


days = int(input())
weights = []
prices = []

def solve():
	total_price = 0
	for day in range(days):
		temp_day = day
		while temp_day < days and weights[temp_day] > 0 and (prices[day] <= prices[temp_day]):
			total_price += weights[temp_day] * prices[day]
			weights[temp_day] = 0
			temp_day += 1
	return total_price
for _ in range(days):
	(weight, price) = map(int, input().split())
	weights.append(weight)
	prices.append(price)
print(solve())


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())
min_meat_cost = float('inf')
ans = 0
for i in range(n):
	(duff_meat, meat_cost) = list(map(int, input().split()))
	min_meat_cost = min(min_meat_cost, meat_cost)
	ans += duff_meat * min_meat_cost
print(ans)


sheet = list()
for day in range(int(input())):
	sheet.append(list(map(int, input().split())))
price = sheet[0][1]
sum = 0
for day in sheet:
	price = min(price, day[1])
	sum += day[0] * price
print(sum)


min_ = 1000
c = 0
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if b < min_:
		min_ = b
	c += a * min_
print(c)


n = int(input())
m = 100
r = 0
while n:
	(a, b) = map(int, input().split())
	m = min(b, m)
	r += a * m
	n -= 1
print(r)


s = 0
minrate = 1000
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	minrate = min(minrate, b)
	s += a * minrate
print(s)


import sys
n = int(input())
count = n
foods = []
prices = []
answer = 0
start = True
while count > 0:
	numbers = list(map(int, input().split()))
	food = numbers[0]
	price = numbers[1]
	if start:
		min_price = price
		start = False
	elif price < min_price:
		min_price = price
	answer += food * min_price
	count = count - 1
print(answer)


class Solution:

	def __init__(self):
		self.__n = int(input())
		(self.__a, self.__p) = ([], [])
		for _ in range(self.__n):
			(_a, _p) = [int(x) for x in input().split()]
			self.__a.append(_a)
			self.__p.append(_p)

	def solve_and_print(self):
		min_price = float('inf')
		min_money = 0
		for (_a, _p) in zip(self.__a, self.__p):
			min_price = min(min_price, _p)
			min_money += min_price * _a
		print(min_money)
Solution().solve_and_print()


n = int(input())
amount = 0
prices = []
days = []
for i in range(n):
	(a, b) = input().split()
	prices.append(int(b))
	days.append(int(a))
while True:
	if len(prices) == 0:
		break
	start = prices.index(min(prices))
	amount += prices[start] * sum(days[start:])
	prices = prices[:start]
	days = days[:start]
print(amount)


days = int(input())
(a, p) = [int(i) for i in input().split()]
counter = a * p
minp = p
for i in range(days - 1):
	(a, p) = [int(i) for i in input().split()]
	if p < minp:
		minp = p
	counter += a * minp
print(counter)


n = int(input())
mp = 101
c = 0
for i in range(n):
	(a, p) = [int(x) for x in input().split()]
	if p < mp:
		mp = p
	c += a * mp
print(c)


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


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)


sum = 0
for i in range(int(input())):
	tmp = [int(i) for i in input().split()]
	min = min if 'min' in vars() and min < tmp[1] else tmp[1]
	sum += min * tmp[0]
print(sum)


n = int(input())
(a, p) = map(int, input().split())
mi = p
ans = p * a
for f in range(n - 1):
	(a, p) = map(int, input().split())
	if p < mi:
		mi = p
	ans += mi * a
print(ans)


def main():
	n = int(input())
	(amt, price) = map(int, input().split())
	total = amt * price
	prevPrice = price
	for _ in range(n - 1):
		(amt, price) = map(int, input().split())
		if price < prevPrice:
			total += amt * price
			prevPrice = price
		else:
			total += prevPrice * amt
	print(total)
main()


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())
(x, y) = [*map(int, input().split())]
minp = y
ans = x * y
for i in range(n - 1):
	(x, y) = [*map(int, input().split())]
	if minp > y:
		minp = y
	ans += x * minp
print(ans)


n = int(input())
a = [0] * n
p = [0] * n
for i in range(n):
	l = [int(x) for x in input().split(' ')]
	a[i] = l[0]
	p[i] = l[1]
s = p[0] * a[0]
min_p = p[0]
for i in range(1, n):
	min_p = min(min_p, p[i])
	s += min_p * a[i]
print(s)


(x, ans) = (999, 0)
for i in range(int(input())):
	(a, p) = map(int, input().split())
	x = min(x, p)
	ans += a * x
print(ans)


n = int(input())
ans = 0
price = 9999999
for _ in range(n):
	(a, b) = map(int, input().split())
	price = min(price, b)
	ans += price * a
print(ans)


n = int(input())
summ = 0
price = 101
for _ in range(n):
	(a, p) = map(int, input().split())
	if price > p:
		price = p
	summ += a * price
print(summ)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
x = []
l = []
q = 10 ** 9
for _ in range(t):
	(a, b) = M()
	l.append(a)
	x.append(b)
ans = 0
for i in range(t):
	if x[i] <= q:
		q = x[i]
		ans += l[i] * q
	else:
		ans += l[i] * q
print(ans)


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


ndays = int(input())
price = 100
money = 0
while ndays:
	(need, p) = map(int, input().split())
	if p < price:
		price = p
	money += price * need
	ndays -= 1
print(money)


n = int(input())
m = 0
p = n * [0]
a = n * [0]
for i in range(n):
	(a[i], p[i]) = [int(i) for i in input().split()]
t = 0
h = 0
i = 0
z = p[0]
for i in range(n):
	if p[i] < z:
		z = p[i]
	m += z * a[i]
print(m)


price = []
amount = []
products = []
optimal_price = 0
minimum = 120
n = int(input())
for j in range(n):
	(sle, ele) = input().split()
	sle = int(sle)
	ele = int(ele)
	amount.append(sle)
	price.append(ele)
for (idx, item) in enumerate(price):
	if item > minimum:
		price[idx] = minimum
	else:
		minimum = price[idx]
for (num1, num2) in zip(price, amount):
	products.append(num1 * num2)
for gle in range(0, len(products)):
	optimal_price = optimal_price + products[gle]
print(optimal_price)


n = int(input())
minp = 1000
result = 0
for _ in range(n):
	(a, p) = map(int, input().split())
	minp = min(minp, p)
	result += minp * a
print(result)


n = int(input())
dados = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	dados.append((a, b))
ans = 0
i = 0
while i < n:
	compra = dados[i][0]
	j = i + 1
	while j < n and dados[j][1] > dados[i][1]:
		compra += dados[j][0]
		j += 1
	ans += compra * dados[i][1]
	i = j
print(ans)


import sys
n = int(sys.stdin.readline().rstrip('\n'))
minPrice = sys.maxsize
result = 0
while n > 0:
	(meatNeeded, pricePerKg) = map(int, sys.stdin.readline().rstrip('\n').split())
	if pricePerKg < minPrice:
		minPrice = pricePerKg
	result += meatNeeded * minPrice
	n -= 1
print(result)


import itertools as it
import functools
import operator
import collections
import math
import sys

def solve2(pairs):
	n = len(pairs)
	(amounts, prices) = list(zip(*pairs))
	cost = 0
	while n > 0:
		(day, min_price) = min(enumerate(prices[:n]), key=operator.itemgetter(1))
		cost += min_price * sum(amounts[day:n])
		n = day
	return cost

def solve(pairs):
	if pairs:
		day_price_pairs = [(i, p) for (i, (_, p)) in enumerate(pairs)]
		amount_needed = [a for (a, _) in pairs]
		(day, min_price) = min(day_price_pairs, key=operator.itemgetter(1))
		meat = sum(amount_needed[day:])
		return min_price * meat + solve(pairs[:day])
	else:
		return 0

def print_stderr(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def main():
	n = int(input())
	pairs = [[int(i) for i in input().strip().split()] for _ in range(n)]
	result = solve2(pairs)
	print(result)
main()


import sys

def mincost(req, price):
	minimum = sys.maxsize
	cost = 0
	for i in range(len(price)):
		minimum = min(minimum, price[i])
		cost += req[i] * minimum
	return cost
n = int(input())
price = []
req = []
for i in range(n):
	sample = list(map(int, input().strip().split(' ')))
	req.append(sample[0])
	price.append(sample[1])
print(mincost(req, price))


n = int(input())
a = []
p = []
min_price = 999
answer = 0
for i in range(n):
	(q, w) = map(int, input().split())
	a.append(q)
	p.append(w)
for i in range(n):
	if p[i] < min_price:
		min_price = p[i]
	answer += a[i] * min_price
print(answer)


n = int(input())
a = []
p = []
for i in range(n):
	inp = input().split()
	a.append(int(inp[0]))
	p.append(int(inp[1]))
answ = 0
price = 101
for i in range(n):
	price = min(price, p[i])
	answ += price * a[i]
print(answ)


n = int(input())
price = []
total = 0
for i in range(n):
	(a, p) = input().split()
	(a, p) = (int(a), int(p))
	if price == [] or p <= price[-1]:
		x = p
	elif p > price[-1]:
		x = price[-1]
	total = total + a * x
	price.append(x)
print(total)


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


ans = 0
for i in range(int(input())):
	(x, y) = map(int, input().split())
	if i == 0 or y < p:
		p = y
	ans = ans + p * x
print(ans)


n = int(input())
P = 101
res = 0
for _ in range(n):
	(a, p) = [int(s) for s in input().split(' ')]
	if p < P:
		P = p
	res += a * P
print(res)


n = int(input())
ans = 0
cheapest = 1000
for i in range(n):
	(needed, price) = map(int, input().split())
	cheapest = min(cheapest, price)
	ans += cheapest * needed
print(ans)


a = []
p = []
n = int(input())
for i in range(n):
	l = list(map(int, input().split(' ')))
	a.append(l[0])
	p.append(l[1])
if n == 1:
	print(a[0] * p[0])
	exit(0)
i = 0
s = 0
start = int(pow(10, 9))
while i < n - 1:
	if p[i] < p[i + 1]:
		start = p[i]
		while i < n - 1 and start <= p[i + 1]:
			s += start * a[i]
			i += 1
			if i == n - 1:
				s += min(start, p[i]) * a[i]
				print(s)
				exit(0)
		s += start * a[i]
	else:
		s += p[i] * a[i]
	i += 1
	if i == n - 1:
		s += min(start, p[i]) * a[i]
print(s)


n = int(input())
t = cost = 0
(a, p) = map(int, input().split())
MIN = p
cost = a * p
for i in range(1, n):
	(a, p) = map(int, input().split())
	if p > MIN:
		cost += a * MIN
	else:
		MIN = p
		cost += a * MIN
print(cost)


n = int(input())
p_min = 101
total = 0
for i in range(n):
	(a, p) = [int(s) for s in input().split(' ')]
	if p < p_min:
		p_min = p
	total += p_min * a
print(total)


n = int(input())
min = 1000
res = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if p < min:
		min = p
	res += a * min
print(res)


n = int(input())
lp = 100
cost = 0
for i in range(n):
	(a, p) = [int(i) for i in input().split()]
	lp = min(p, lp)
	cost += lp * a
print(cost)


loop = input()
days = []
cost = []
total_cost = 0
for i in range(int(loop)):
	x = input()
	days.append(int(x.split()[0]))
	cost.append(int(x.split()[1]))
	if i == 0:
		min_cost = cost[0]
	if cost[i] < min_cost:
		total_cost += days[i] * cost[i]
		min_cost = cost[i]
	else:
		total_cost += days[i] * min_cost
print(total_cost)


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().split()))
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
apet = []
price = []
for __ in range(n):
	(x, y) = int_array()
	apet.append(x)
	price.append(y)
ans = 0
mini = INF
for i in range(n):
	mini = min(mini, price[i])
	ans += apet[i] * mini
print(ans)


__author__ = 'artyom'

def main():
	t = 0
	c = 101
	n = read()
	for _ in range(n):
		(a, p) = read(3)
		if p < c:
			c = p
		t += a * c
	return t

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
res = main()
write(res)


v = []
for _ in range(int(input())):
	a = list(map(int, input().split()))
	v.append(a)
(p, s) = (101, 0)
for i in v:
	p = min(p, i[1])
	s += p * i[0]
print(s)


import sys
n = int(sys.stdin.readline())
a = []
p = []
for it in range(n):
	(ai, pi) = map(int, sys.stdin.readline().split())
	a.append(ai)
	p.append(pi)
cost = p[0] * a[0]
currmin = p[0]
for i in range(1, n):
	currmin = min(p[i], currmin)
	cost += a[i] * currmin
print(cost)


n = int(input())
money = 0
minprice = 200
for i in range(n):
	(x, y) = map(int, input().split())
	minprice = min(y, minprice)
	money += x * minprice
print(money)


n = int(input())
a = []
b = []
for i in range(n):
	s = input().split()
	a.append(int(s[0]))
	b.append(int(s[1]))
ans = 0
cur = 1000000000
for i in range(n):
	cur = min(cur, b[i])
	ans = ans + cur * a[i]
print(ans)


k = int(input())
min = 101
s = 0
for i in range(k):
	(a, b) = [int(i) for i in input().split()]
	if b < min:
		min = b
	s += a * min
print(s)


cost = 100000
n = int(input())
total = 0
for i in range(0, n):
	(a, b) = map(int, input().split(' '))
	cost = min(cost, b)
	total = total + cost * a
print(total)


n = int(input())
meat = []
price = []
for i in range(n):
	(a, b) = map(int, input().split())
	meat += [a]
	price += [b]
cost = 0
k = 0
for j in range(n):
	if j < n - 1:
		if price[k] <= price[j]:
			cost += price[k] * meat[j]
		else:
			k = j
			cost += price[k] * meat[j]
	elif price[j] >= price[k]:
		cost += price[k] * meat[j]
	else:
		cost += price[j] * meat[j]
print(cost)


num = int(input())
a = []
b = []
for x in range(num):
	temp = input().split(' ')
	b.append(int(temp[0]))
	a.append(int(temp[1]))
	pass
cost = 0
lowestday = num
day = num
while len(a[:lowestday]) > 0:
	c = a[:lowestday]
	lowestprice = min(c)
	lowestday = a.index(min(c))
	if a[lowestday:]:
		cost += sum([lowestprice * x for x in b[lowestday:day]])
		pass
	day = lowestday
	pass
print(cost)


n = int(input())
day = []
price = []
for _ in range(n):
	(d, p) = [int(x) for x in input().split()]
	day.append(d)
	price.append(p)
ans = 0
temp = price[0]
suma = 0
for i in range(n):
	if temp <= price[i]:
		suma += day[i]
	else:
		ans += suma * temp
		temp = price[i]
		suma = day[i]
	if i + 1 == n:
		ans += suma * temp
print(ans)


n = int(input())
min_price = 1000000
amount = 0
for i in range(n):
	(x, y) = map(int, input().split())
	min_price = min(y, min_price)
	amount += min_price * x
print(amount)


n = int(input())
money = 0
price = 1000000
while n:
	(a, p) = map(int, input().split())
	if price > p:
		price = p
	money += price * a
	n -= 1
print(money)


n = int(input())
a = 0
b = 0
pref = [0] * (n + 1)
pref[0] = 100
res = 0
for i in range(1, n + 1):
	(a, b) = map(int, input().split())
	pref[i] = min(pref[i - 1], b)
	res += pref[i] * a
print(res)


n = int(input())
m = 100
res = 0
for i in range(n):
	(a, p) = map(int, input().split())
	m = min(m, p)
	res += a * m
print(res)


n = int(input())
(l, d) = ([], [])
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	d.append(y)
m = 10 ** 10
s = 0
for i in range(n):
	if d[i] < m:
		m = d[i]
	s = s + l[i] * m
print(s)


n = int(input())
a = [0] * n
p = [0] * n
for i in range(n):
	(a[i], p[i]) = [int(s) for s in input().split()]
k = 0
i = 0
while i < n:
	s = a[i]
	j = i + 1
	while j < n and p[i] <= p[j]:
		s += a[j]
		j += 1
	k += s * p[i]
	i = j
print(k)


temp = 0
ans = 0
a = [list(map(int, input().split())) for i in range(int(input()))]
i = 0
while i < len(a):
	temp = a[i][1]
	while i < len(a):
		if temp > a[i][1]:
			temp = a[i][1]
		ans += a[i][0] * temp
		i += 1
print(ans)


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


n = int(input())
p = []
a = []
ans = 0
for j in range(n):
	(c, b) = map(int, input().split())
	p.append(b)
	a.append(c)
price = p[0]
for i in range(n):
	if p[i] < price:
		price = p[i]
	ans += a[i] * price
print(ans)


n = int(input())
k = [0] * 2 * n
j = 0
for i in range(n):
	(a, p) = map(int, input().split())
	(k[j], k[j + 1]) = (a, p)
	j += 2
z = 0
s = k[1]
for i in range(0, len(k), 2):
	s = min(k[i + 1], s)
	if s < k[i + 1]:
		z += k[i] * s
	else:
		z += k[i] * k[i + 1]
print(z)


(s, c) = (0, 1000)
for _ in range(int(input())):
	(n, m) = map(int, input().strip().split())
	if m < c:
		c = m
	s += n * c
print(s)


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


n = int(input())
c = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if i == 0:
		m = p
	else:
		m = min(m, p)
	c += a * m
print(c)


n = int(input())
lst = []
for i in range(n):
	lst.append([int(i) for i in input().split()])
totalMoneyNeeded = 0
auxCost = 1000000000
auxNum = 0
for i in lst:
	if i[1] < auxCost:
		totalMoneyNeeded += auxNum * auxCost
		auxCost = i[1]
		auxNum = i[0]
	else:
		auxNum += i[0]
totalMoneyNeeded += auxNum * auxCost
print(totalMoneyNeeded)


ans = []
for _ in range(int(input())):
	(a, p) = map(int, input().split())
	ans.append([_ + 1, a, p])
ans.sort(key=lambda x: (x[0], x[1]))
total = ans[0][2] * ans[0][1]
final = ans[0][2]
for i in range(1, len(ans)):
	if final > ans[i][2]:
		total += ans[i][2] * ans[i][1]
		final = ans[i][2]
	else:
		total += ans[i][1] * final
print(total)


n = int(input())
(m, d) = map(int, input().split())
dmin = d
s = m * d
while n - 1:
	(m, d) = map(int, input().split())
	if dmin > d:
		dmin = d
	s += m * dmin
	n -= 1
print(s)


t = int(input())
s = t
sum = 0
while t > 0:
	(a, p) = list(map(int, input().split()))
	if s == t:
		sum += a * p
		x = p
	elif x < p:
		sum += x * a
	else:
		sum += p * a
		x = p
	t -= 1
print(sum)


import sys
n = int(input())
ap = list((int(s) for i in range(n) for s in sys.stdin.readline().split()))
a = ap[::2]
p = ap[1::2]
r = len(a)
s = 0
while r > 0:
	i = p.index(min(p[:r]))
	price = p[i]
	s += sum(a[i:r]) * price
	r = i
print(s)


n = int(input())
needs = []
prices = []
for i in range(n):
	w = [int(x) for x in input().split()]
	needs += [w[0]]
	prices += [w[1]]
date = 0
payment = 0
while date <= n - 1:
	for j in range(date, n):
		if prices[j] >= prices[date]:
			payment += prices[date] * needs[j]
			if j == n - 1:
				date = n
		else:
			date = j
			break
print(payment)


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def solve(a, p):
	min_ = p[0]
	min_array = [0] * len(p)
	min_array[0] = min_
	sum_ = min_ * a[0]
	for i in range(1, len(p)):
		if p[i] < min_:
			min_ = p[i]
		min_array[i] = min_
		sum_ += min_ * a[i]
	print(str(sum_))
t = int(input())
a = [0] * t
p = [0] * t
for i in range(t):
	(a[i], p[i]) = to_list(input())
solve(a, p)


n = int(input())
(y, s) = (101, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	if y > b:
		y = b
	s += a * y
print(s)


n = int(input())
amts = [0] * n
pri = [0] * n
for i in range(n):
	(amt, p) = map(int, input().split())
	amts[i] = amt
	pri[i] = p
cheapest = pri[0]
exp = 0
for i in range(n):
	cheapest = min(cheapest, pri[i])
	exp += amts[i] * cheapest
print(exp)


n = int(input())
r = 0
s = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if i == 0:
		r = y
	if r >= y:
		r = y
	s += x * r
print(s)


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


n = int(input())
l = []
total_meat = 0
for i in range(n):
	m = list(map(int, input().split()))
	l.append(m)
total_cost = l[0][1] * l[0][0]
min_meat = l[0][1]
for i in range(1, n):
	if min_meat >= l[i][1]:
		min_meat = l[i][1]
	total_cost += l[i][0] * min_meat
print(total_cost)


meat_total = 0
strategic_min_price = 100000
for _ in range(int(input())):
	(a, p) = (int(x) for x in input().split())
	if p < strategic_min_price:
		strategic_min_price = p
		meat_total += a * strategic_min_price
	else:
		meat_total += a * strategic_min_price
print(meat_total)


dias = int(input())
kilos = []
precios = []
suma = 0
total = 0
contador2 = 0
ultimo = False
for i in range(dias):
	datos = list(str(input()).split())
	datos[0] = int(datos[0])
	datos[1] = int(datos[1])
	kilos.append(datos[0])
	precios.append(datos[1])
for i in range(len(precios)):
	cantidad = precios[i]
	contador = i
	if contador2 - i > 0:
		continue
	for j in range(i, len(precios)):
		if precios[j] < cantidad:
			suma = 0
			for h in range(i, j):
				suma += kilos[h]
			total += suma * cantidad
			contador2 = j
			break
		elif j + 1 == len(precios):
			suma = 0
			for k in range(i, len(precios)):
				suma += kilos[k]
			total += suma * cantidad
			ultimo = True
			break
	if ultimo:
		break
print(total)


n = int(input())
m = []
cun = 0
qian = 0
for i in range(n):
	m.append([int(x) for x in input().split()])
for i in range(n):
	if cun < m[i][0]:
		qian += m[i][1] * (m[i][0] - cun)
		cun = 0
	else:
		cun -= m[i][0]
	if cun == 0:
		for j in range(i + 1, n):
			if m[i][1] < m[j][1]:
				qian += m[i][1] * m[j][0]
				cun += m[j][0]
			else:
				break
print(qian)


n = int(input())
pmin = 101
sm = 0
while n > 0:
	n -= 1
	s = input()
	a = s.split(' ')
	(a, p) = (int(a[0]), int(a[1]))
	if p < pmin:
		pmin = p
	sm += a * pmin
print(sm)


n = int(input())
mass = []
price = []
for i in range(n):
	(a, b) = [int(t) for t in input().split()]
	mass.append(a)
	price.append(b)
A = 0
while len(mass) != 0:
	k = min(price)
	P = price.index(k)
	A += sum(mass[P:]) * k
	price = price[:P]
	mass = mass[:P]
print(A)


import math

def main():
	n = int(input())
	a = []
	m = 101
	p = 0
	for i in range(n):
		a.append(list(map(int, input().split())))
		if m > a[i][1]:
			m = a[i][1]
			p = i
	s = 0
	mt = 101
	for i in range(n):
		if i < p:
			if mt > a[i][1]:
				mt = a[i][1]
			s = s + a[i][0] * mt
		else:
			s = s + a[i][0] * m
	print(s)
main()


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())
a = []
b = []
for i in range(n):
	(a1, p1) = [int(x) for x in input().split()]
	a.append(a1)
	b.append(p1)
k = a[0] * b[0]
v = b[0]
for i in range(1, n):
	if b[i] < v:
		v = b[i]
	k += a[i] * v
print(k)


n = int(input())
array = [list(map(int, input().split())) for x in range(n)]
price = 0
minPrice = array[0][1]
for i in range(n):
	minPrice = min(array[i][1], minPrice)
	price += array[i][0] * minPrice
print(price)


n = int(input())
min_p = 100
ans = 0
for _ in range(n):
	(a, p) = map(int, input().split())
	min_p = min(min_p, p)
	ans += a * min_p
print(ans)


n = int(input())
price = 10000000
ans = 0
for _ in range(n):
	(a, p) = list(map(int, input().split()))
	price = min(price, p)
	ans += a * price
print(ans)


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
money = l[0][0] * l[0][1]
minm = l[0][1]
for i in range(1, n):
	if l[i][1] < minm:
		money += l[i][0] * l[i][1]
		minm = l[i][1]
	else:
		money += l[i][0] * minm
print(money)


def inp():
	return map(int, input().split())
n = int(input())
(total, min) = (0, 0)
for i in range(n):
	(a, p) = inp()
	if i == 0 or p < min:
		min = p
	total += min * a
print(total)


import sys
n = int(input())
cur_min = 101
res = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if p < cur_min:
		cur_min = p
	res += a * cur_min
print(res)


import sys
n = int(input())
lp = sys.maxsize
amount = 0
for i in range(n):
	(a, p) = [int(item) for item in input().split()]
	if p < lp:
		lp = p
	amount += lp * a
print(amount)


n = int(input())
kilos = []
precios = []
costo_total = 0
for i in range(n):
	(k, p) = list(map(int, input().split(' ')))
	kilos.append(k)
	precios.append(p)
menor = 101
for i in range(n):
	if menor >= precios[i]:
		menor = precios[i]
	costo_total += kilos[i] * menor
print(costo_total)


n = int(input())
menor = 101
s = 0
for k in range(n):
	(a, b) = map(int, input().split(' '))
	if b < menor:
		menor = b
	s += a * menor
print(s)


n = int(input())
ans = 0
price = 1000
for u in range(n):
	(a, p) = (int(i) for i in input().split())
	price = min(price, p)
	ans += a * price
print(ans)


n = int(input())
m = 1000
res = 0
for i in range(n):
	s = input().split()
	(a, b) = (int(s[0]), int(s[1]))
	if m > b:
		m = b
	res += a * m
print(res)


n = int(input())
(cnt, min_price) = (0, 101)
for i in range(n):
	(a, b) = map(int, input().split())
	min_price = min(min_price, b)
	cnt += a * min_price
print(cnt)


n = int(input())
(a, p) = map(int, input().split())
min_p = p
total = a * p
for i in range(n - 1):
	(a, p) = map(int, input().split())
	if p < min_p:
		min_p = p
	total += a * min_p
print(total)


s = []
n = int(input())
i = 1
for _ in [0] * n:
	s.append([int(i) for i in input().split()])
b = s[0][1]
t = s[0][0] * b
while i < n:
	while i < n and s[i][1] > b:
		t += s[i][0] * b
		i += 1
	if i >= n:
		break
	b = s[i][1]
	t += s[i][0] * b
	i += 1
print(t)


class pairs:

	def __init__(self, fir, sec):
		self.first = fir
		self.second = sec
l = []
for i in range(int(input())):
	(fir, sec) = map(int, input().split())
	item = pairs(fir, sec)
	l.append(item)
mi = l[0].second
tot = 0
for e in l:
	if e.second <= mi:
		mi = e.second
	tot += mi * e.first
print(tot)


a = []
p = []
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a.append(x)
	p.append(y)
cost = a[0] * p[0]
for i in range(1, len(a)):
	if p[i] > p[i - 1]:
		p[i] = p[i - 1]
		cost += a[i] * p[i]
	else:
		cost += a[i] * p[i]
print(cost)


def main():
	n = int(input())
	duff = []
	cost = []
	for i in range(n):
		x = input().split()
		duff.append(int(x[0]))
		cost.append(int(x[1]))
	money = 0
	i = 0
	end = False
	while i <= n - 1:
		if i < n - 1:
			if cost[i] > cost[i + 1]:
				money += duff[i] * cost[i]
				i += 1
			else:
				needed = duff[i]
				j = i + 1
				min_cost = cost[i]
				while j <= n - 1 and cost[i] <= cost[j]:
					needed += duff[j]
					j += 1
				money += min_cost * needed
				i = j
		elif i == n - 1:
			money += duff[i] * cost[i]
			i += 1
	print(money)
main()


n = int(input())
l = []
for i in range(n):
	(a, p) = map(int, input().split())
	l.append((a, p))
pri = 9999999999
tot = 0
for i in range(n):
	if pri > l[i][1]:
		pri = l[i][1]
	tot += l[i][0] * pri
print(tot)


t = int(input())
p = 101
sum = 0
for i in range(1, t + 1, 1):
	(a, b) = map(int, input().split())
	if p > b:
		p = b
	sum += p * a
print(sum)


n = int(input())
pMin = 101
tot = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if pMin > p:
		pMin = p
	tot += pMin * a
print(tot)


n = int(input())
amount = []
cost = []
for i in range(n):
	(a, c) = [int(x) for x in input().split(' ')]
	amount.append(a)
	cost.append(c)
mn = 142
ans = 0
for z in range(n):
	mn = min(mn, cost[z])
	ans += amount[z] * mn
print(ans)


n = int(input())
ans = 0
curMin = 1e+30
for i in range(n):
	(a, p) = (int(x) for x in input().split())
	curMin = min(curMin, p)
	ans += a * curMin
print(ans)


n = int(input())
mi = 100000000000000
ans = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if b < mi:
		ans += a * b
		mi = b
	else:
		ans += a * mi
print(ans)


n = int(input())
ans = 0
mn = 1000
for i in range(n):
	(a, p) = map(int, input().split())
	mn = min(mn, p)
	ans += a * mn
print(ans)


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


n = int(input())
mi = None
an = 0
for i in range(n):
	(e, c) = map(int, input().split())
	if not mi:
		mi = c
	else:
		mi = min(mi, c)
	an += e * mi
print(an)


n = int(input())
c = 110
s = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if c > b:
		c = b
	s += a * c
print(s)


N = int(input())
sol = 0
m = 101
for i in range(N):
	(a, b) = map(int, input().split())
	m = min(m, b)
	sol += a * m
print(sol)


n = int(input())
a = [0] * n
p = [0] * n
for i in range(n):
	(x, b) = map(int, input().split())
	a[i] = x
	p[i] = b
k1 = n
k = n
summ = 0
while k != 0:
	k = p[:k1].index(min(p[:k1]))
	summ += sum(a[k:k1]) * p[k]
	k1 = k
print(summ)


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())
m = 100
t = 0
for i in range(n):
	(a, b) = map(int, input().split())
	m = min(m, b)
	t = t + a * m
print(t)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if ll[mid] <= val:
			ans = mid
			return binary(mid + 1, r, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)
n = int(stdin.readline())
mini = 1000
total = 0
for i in range(n):
	(a, b) = map(int, stdin.readline().split(' '))
	if mini > b:
		mini = b
	total += a * mini
stdout.write(str(total) + '\n')


n = int(input())
(a, p) = ([], [])
for i in range(n):
	in1 = input().split()
	a.append(int(in1[0]))
	p.append(int(in1[1]))
mco = 0
id = 0
while id < n:
	pp = p[id]
	for i in range(id, n):
		if p[id] > p[i]:
			id = i
			break
		mco += pp * a[i]
	else:
		break
print(mco)


n = int(input())
l = []
for i in range(n):
	(a, p) = [int(i) for i in input().split()]
	l.append([a, p])
initial = l[0][1]
s = l[0][0] * initial
for i in range(1, n):
	if l[i][1] >= initial:
		s += l[i][0] * initial
	else:
		initial = l[i][1]
		s += initial * l[i][0]
print(s)


n = int(input())
lst = []
ans = 0
for i in range(n):
	(a, p) = map(int, input().split())
	lst.append((a, p))
i = 0
while i <= n - 1:
	for j in range(i, n):
		if lst[i][1] <= lst[j][1]:
			ans += lst[i][1] * lst[j][0]
		else:
			i = j
			break
	else:
		break
print(ans)


arr = []
arrN = []
rs = 0
n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	arr.append(b)
	arrN.append(a)
rs = arr[0] * arrN[0]
minA = arr[0]
for i in range(1, n):
	if arr[i] < minA:
		minA = arr[i]
	rs += minA * arrN[i]
print(rs)


from sys import *
inp = lambda : stdin.readline()

def main():
	n = int(inp())
	(ans, prevmin) = (0, int(10000000000.0))
	for i in range(n):
		(a, b) = map(int, inp().split())
		prevmin = min(b, prevmin)
		ans += a * prevmin
	print(ans)
main()


def minimise_expense(n, meat_kg_list, meat_price_list):
	min_price = 101
	expense = 0
	for (idx, price) in enumerate(meat_price_list):
		if price < min_price:
			min_price = price
		expense += meat_kg_list[idx] * min_price
	return expense
n = int(input())
meat_kg_list = []
meat_price_list = []
for __ in range(n):
	(kg, price) = list(map(int, input().split()))
	meat_kg_list.append(kg)
	meat_price_list.append(price)
expense = minimise_expense(n, meat_kg_list, meat_price_list)
print(expense)


n = int(input())
spent = 0
best_price = 101
for i in range(n):
	(needed, price) = map(int, input().split())
	best_price = min(best_price, price)
	spent += needed * best_price
print(spent)


tam = int(input())
soma = 0
meat = []
cost = []
for i in range(0, tam):
	entrada = input().split(' ')
	meat.append(int(entrada[0]))
	cost.append(int(entrada[1]))
soma += meat[0] * cost[0]
menor = cost[0]
for j in range(1, tam):
	if menor > cost[j]:
		menor = cost[j]
	soma += menor * meat[j]
print(soma)


from math import inf
(min_price, total) = (inf, 0)
for _ in range(int(input())):
	(a, p) = map(int, input().split())
	min_price = min(p, min_price)
	total += a * min_price
print(total)


n = int(input())
(a, p) = ([0] * n, [0] * n)
for i in range(n):
	(a[i], p[i]) = [int(x) for x in input().split()]
curr_min = p[0]
cost = a[0] * p[0]
for i in range(1, n):
	if p[i] < curr_min:
		curr_min = p[i]
	cost += a[i] * curr_min
print(cost)


n = int(input())
(a, p) = map(int, input().split())
money = a * p
for i in range(n - 1):
	(a, q) = map(int, input().split())
	if q < p:
		p = q
	money += a * p
print(money)


n = int(input())
ans = 0
ok = 10 ** 9
for i in range(n):
	(a, b) = map(int, input().split())
	ok = min(ok, b)
	ans += ok * a
print(ans)


total_cost = 0
day_cost = 101
for i in range(int(input())):
	(ai, pi) = [int(i) for i in input().split()]
	day_cost = min(day_cost, pi)
	total_cost += day_cost * ai
print(total_cost)


n = int(input())
ans = 0
minprice = 100
for _ in range(n):
	(a, p) = map(int, input().split())
	if p <= minprice:
		minprice = p
	ans += a * minprice
print(ans)


n = int(input())
money = 100
sum = 0
for i in range(n):
	(a, p) = map(int, input().split())
	money = min(money, p)
	sum += a * money
print(sum)


n = int(input())
s = 0
a = []
b = []
for i in range(0, n):
	x = input()
	xx = x.split()
	a.append(int(xx[0]))
	b.append(int(xx[1]))
if len(a) == 1:
	print(a[0] * b[0])
else:
	i = 0
	while i != n:
		if i != n - 1:
			h = i
			s += b[i] * a[i]
			q = 0
			while b[i] < b[h + 1]:
				s += b[i] * a[h + 1]
				h += 1
				q += 1
				if h == n - 1:
					break
			if q != 0:
				i = h + 1
			else:
				i += 1
		else:
			if i != h:
				s += b[i] * a[i]
			i += 1
	print(s)


n = int(input())
(a, m) = map(int, input().split())
ans = a * m
for i in range(n - 1):
	(b, c) = map(int, input().split())
	m = min(m, c)
	ans += b * m
print(ans)


z = 101
s = 0
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if y < z:
		s += x * y
		z = y
	else:
		s += x * z
print(s)


n = int(input())
ans = 0
mi = 10 ** 40
for i in range(n):
	(x, y) = map(int, input().split())
	mi = min(mi, y)
	ans += x * mi
print(ans)


t = int(input())
kg = []
cost = []
spent = 0
for x in range(t):
	(a, b) = input().split()
	kg.append(int(a))
	cost.append(int(b))
cheap = cost[0]
for (x, y) in zip(kg, cost):
	if y >= cheap:
		spent += x * cheap
	else:
		cheap = y
		spent += x * cheap
print(spent)


n = int(input())
e = []
c = []
for i in range(n):
	s = [int(a) for a in input().split()]
	e.append(s[0])
	c.append(s[1])
ex = c[0]
m = 0
cnt = 0
while m < n:
	cnt = cnt + e[m] * ex
	m = m + 1
	if m == n:
		break
	if c[m] < ex:
		ex = c[m]
print(cnt)


n = int(input())
p = 10000
c = 0
for i in range(n):
	(a, b) = map(int, input().split())
	p = min(p, b)
	c += a * p
print(c)


n = int(input())
listOfamount = [None] * n
listofprice = [None] * n
res = 0
for i in range(n):
	(amount, price) = map(int, input().split())
	listOfamount[i] = amount
	listofprice[i] = price
minn = 0
for i in range(n):
	if i == 0:
		res = res + listOfamount[i] * listofprice[i]
		minn = listofprice[i]
	else:
		if listofprice[i] < minn:
			minn = listofprice[i]
		res = res + listOfamount[i] * minn
print(res)


n = int(input().strip())
ans = 0
m = 100
for _ in range(n):
	(a, p) = map(int, input().strip().split(' '))
	m = min(m, p)
	ans += a * m
print(ans)


n = int(input())
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
price = 2000000000
ans = 0
for i in range(n):
	price = min(price, b[i])
	ans += price * a[i]
print(ans)


x = int(input())
a = 101
tot = 0
for i in range(x):
	(y, z) = map(int, input().split())
	a = min(a, z)
	tot += a * y
print(tot)


a = int(input())
z = a
x = 0
y = []
k = 3
j = 0
h = 0
l = 1
while 1 <= z <= 100000:
	b = input().split()
	y.extend(b)
	z = z - 1
h = int(y[j])
if a == 1:
	x = int(y[0]) * int(y[1])
while k <= a * 2 - 1:
	if int(y[l]) <= int(y[k]):
		j = j + 2
		h = h + int(y[j])
		if k == a * 2 - 1:
			x = x + int(y[l]) * h
			break
		k = k + 2
	elif int(y[l]) > int(y[k]):
		x = x + int(y[l]) * h
		l = k
		j = j + 2
		h = int(y[j])
		if k == a * 2 - 1:
			x = x + int(y[l]) * h
			break
		k = k + 2
print(x)


n = int(input())
a = []
p = []
for i in range(n):
	(a1, p1) = map(int, input().split())
	a.append(a1)
	p.append(p1)
k = p[0]
r = 0
for i in range(len(p)):
	k = min(k, p[i])
	r = r + k * a[i]
print(r)


n = int(input())
a = []
p = []
index = 101
ans = 0
for i in range(0, n):
	(ai, pi) = input().split()
	a.append(int(ai))
	p.append(int(pi))
for i in range(0, len(a)):
	index = min(index, p[i])
	ans += index * a[i]
print(ans)


N = int(input())
min_cost = float('inf')
res = 0
for n in range(N):
	(a, p) = map(int, input().split())
	min_cost = min(min_cost, p)
	res += min_cost * a
print(res)


def read_ints():
	return [int(i) for i in input().split()]

def read_int():
	return read_ints()[0]

def solve():
	n = read_int()
	days = [read_ints() for _ in range(n)]
	total = 0
	min_price = 101
	for (count, price) in days:
		min_price = min(min_price, price)
		total += count * min_price
	print(total)
solve()


n = int(input())
c = 0
p = 100
for i in range(n):
	(m, t) = map(int, input().split())
	p = min(t, p)
	c += m * p
print(c)


import math
n = int(input())
answer = 0
price = math.inf
for i in range(n):
	(a, p) = tuple(map(int, input().split()))
	price = min(price, p)
	answer += price * a
print(answer)


n = int(input())
(x, c) = (101, 0)
for _ in range(n):
	(a, p) = map(int, input().split())
	x = min(x, p)
	c += x * a
print(int(c))


n = int(input())
a = []
p = []
for i in range(n):
	(ai, pi) = map(int, input().split())
	a.append(ai)
	p.append(pi)
cost = 0
k = 0
while k < n - 1:
	for j in range(k, n):
		if p[j] < p[k]:
			j -= 1
			break
	cost += sum(a[k:j + 1]) * p[k]
	k = j + 1
if k == n - 1:
	cost += a[k] * p[k]
print(cost)


import sys
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())
ans = 0
b = 101
for i in range(n):
	temp = [int(s) for s in input().split()]
	b = min(b, temp[1])
	ans += temp[0] * b
print(ans)


n = int(input())
c = []
d = []
for i in range(n):
	(a, b) = map(int, input().split())
	c.append(a)
	d.append(b)
t = sum(c)
m = d[0]
p = d[0] * t
for i in range(1, n):
	t = t - c[i - 1]
	if d[i] < m:
		p = p - t * m + d[i] * t
		m = d[i]
print(p)


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


amount = int(input())
minCost = 450
answer = 0
for i in range(amount):
	(need, cost) = map(int, input().split())
	if cost < minCost:
		minCost = cost
	answer += need * minCost
print(answer)


n = int(input())
ap = [tuple(map(int, input().split())) for _ in range(n)]
ans = 0
min_so_far = 100
for i in range(n):
	if ap[i][1] > min_so_far:
		ans += ap[i][0] * min_so_far
	else:
		ans += ap[i][0] * ap[i][1]
		min_so_far = ap[i][1]
print(ans)


days = int(input())
needs = 0
costs = 1000
for i in range(days):
	(need, cost) = map(int, input().split())
	costs = min(costs, cost)
	needs += need * costs
print(needs)


n = int(input())
i = 0
data = list()
while i < n:
	num = input()
	arr = []
	counting = 0
	for m in range(0, len(num)):
		if num[m] == ' ':
			arr.append(int(num[counting:m]))
			counting = m + 1
		elif m == len(num) - 1:
			arr.append(int(num[counting:len(num)]))
	data.append(arr)
	i += 1
money = 0
check = None
for i in range(len(data)):
	if i == 0:
		money = data[i][0] * data[i][1]
		check = data[i][1]
	elif check < data[i][1]:
		money += data[i][0] * check
	else:
		money += data[i][0] * data[i][1]
		check = data[i][1]
print(money)


n = int(input())
current_min = 2 ** 30
ans = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	current_min = min(current_min, y)
	ans += x * current_min
print(ans)


n = int(input())
quantity = []
price = []
for i in range(n):
	(q, p) = map(int, input().split())
	quantity.append(q)
	price.append(p)
s = price[0] * quantity[0]
m = price[0]
for i in range(1, n):
	if price[i] < m:
		m = price[i]
	s += m * quantity[i]
print(s)


import math
n = int(input())
n = int(n)
a = []
ans = 0
for i in range(n):
	mp = input().split()
	mp[0] = int(mp[0])
	mp[1] = int(mp[1])
	a.append(mp)
minpos = 0
i = 0
while i < n:
	if a[minpos][1] * a[i][0] > a[i][1] * a[i][0]:
		minpos = i
	ans += a[minpos][1] * a[i][0]
	i += 1
print(ans)


n = int(input())
res = 0
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
p = l[0][1]
for i in range(len(l)):
	if p > l[i][1]:
		p = l[i][1]
	res += l[i][0] * p
print(res)


minn = 101
total = 0
for i in range(0, int(input())):
	(n, k) = [int(i) for i in input().split()]
	minn = min(minn, k)
	total += n * minn
print(total)


n = int(input())
(a0, b0) = map(int, input().split())
s = a0 * b0
for i in range(1, n):
	(a, b) = map(int, input().split())
	if b > b0:
		b = b0
	s += a * b
	b0 = b
print(s)


dias = int(input())
total = 0
preco = 101
for i in range(dias):
	(a, preco_dia) = map(int, input().split())
	preco = min(preco, preco_dia)
	total += a * preco
print(total)


n = int(input())
needed = []
price = []
for i in range(n):
	(need, price_) = map(int, input().split())
	needed.append(need)
	price.append(price_)
total = 0
min_price = 100
for i in range(n):
	if price[i] < min_price:
		min_price = price[i]
	total += needed[i] * min_price
print(total)


n = int(input())
ans = 0
minp = 100
for i in range(n):
	line = list(map(int, input().split()))
	minp = min(minp, line[1])
	ans += int(line[0]) * minp
print(ans)


n = int(input())
price = []
request = []
for i in range(n):
	(a, p) = map(int, input().split())
	price.append(p)
	request.append(a)
money_sum = 0
p = price[0]
for i in range(n):
	if p > price[i]:
		p = price[i]
	c = request[i]
	money_sum += p * c
print(money_sum)


n = int(input())
a = [0] * n
p = [0] * n
for i in range(0, n):
	(a[i], p[i]) = map(int, input().split())
price = p[0]
cost = a[0] * p[0]
for i in range(1, n):
	if price > p[i]:
		price = p[i]
	cost += a[i] * price
print(cost)


N = int(input())
Lowest = 100000
SUM = 0
for i in range(N):
	X = list(map(int, input().split()))
	Lowest = min(Lowest, X[1])
	SUM += X[0] * Lowest
print(SUM)


n = int(input())
lA = []
for i in range(n):
	lB = [int(j) for j in input().split()]
	lA.append(lB)
m = lA[0][1] * lA[0][0]
t = lA[0][1]
k = 1
while k < n:
	s = 0
	if lA[k][1] < t:
		t = lA[k][1]
	m += lA[k][0] * t
	k += 1
print(m)


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


n = int(input())
a = []
p = []
for i in range(n):
	(x, y) = map(int, input().split())
	a += [x]
	p += [y]
m = min(p)
ans = m * sum(a[p.index(m):])
mi = 200
for i in range(p.index(m)):
	if p[i] < mi:
		mi = p[i]
	ans += mi * a[i]
print(ans)


x = int(input())
t = 0
p = []
q = []
for n in range(x):
	if x == 1:
		(a, b) = map(int, input().split())
		t = a * b
	elif n != x - 1:
		(a, b) = map(int, input().split())
		q.append(a)
		if len(p) == 0:
			p.append(b)
		elif b >= p[len(p) - 1]:
			p = p
		else:
			q = q[0:len(q) - 1]
			aa = sum(q)
			t = t + aa * p[0]
			q = []
			q.append(a)
			p = []
			p.append(b)
	else:
		(a, b) = map(int, input().split())
		if b >= p[len(p) - 1]:
			q.append(a)
			p.append(b)
			p.sort()
			aa = sum(q)
			t = t + aa * p[0]
		else:
			aa = sum(q)
			t = t + p[0] * aa
			q = []
			p = []
			q.append(a)
			p.append(b)
			t = t + q[len(q) - 1] * p[len(p) - 1]
print(t)


from math import inf
t = int(input())
(a, p) = ([], [])
for _ in range(t):
	(an, pn) = list(map(int, input().split()))
	a.append(an)
	p.append(pn)
cur_min = inf
total = 0
for i in range(len(a)):
	cur_min = min(cur_min, p[i])
	total += cur_min * a[i]
print(total)


n = int(input())
mincost = 101
sm = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if b < mincost:
		mincost = b
	sm += a * mincost
print(sm)


import math

def main():
	n = int(input())
	s = 0
	mt = 101
	for i in range(n):
		(a, b) = map(int, input().split())
		if mt > b:
			mt = b
		s = s + a * mt
	print(s)
main()


n = int(input())
(a, p) = ([], [])
for i in range(n):
	(ai, pi) = [int(d) for d in input().split()]
	a.append(ai)
	p.append(pi)
ans = 0
k = n
t = 0
q = sorted(enumerate(p), key=lambda x: (x[1], x[0]))
while k > 0:
	(i, v) = q[t]
	ans += v * sum(a[i:k])
	k = i
	while t < n and q[t][0] >= i:
		t += 1
print(ans)


days = int(input())
kgprice = [list(map(int, input().split())) for _ in range(days)]
max_costs = 0
lowest_price = kgprice[0][1]
for i in kgprice:
	if i[1] < lowest_price:
		lowest_price = i[1]
	max_costs += i[0] * lowest_price
print(max_costs)


t = int(input())
l = []
l1 = []
l2 = []
x = 1000000000
for _ in range(t):
	(a, b) = map(int, input().split())
	l.append(a)
	l1.append(b)
for i in range(len(l1)):
	x = min(x, l1[i])
	l2.append(l[i] * x)
print(sum(l2))


n = int(input())
a = [i for i in range(n)]
b = [i for i in range(n)]
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
m = b[0]
c = 0
for i in range(n):
	if b[i] < m:
		m = b[i]
	c += a[i] * m
print(c)


n = int(input())
s = 0
p = 101
for _ in range(n):
	(a, p_n) = map(int, input().split())
	p = min(p, p_n)
	s += a * p
print(s)


n = int(input())
min_price = float('inf')
res = 0
for i in range(n):
	(a, p) = [int(x) for x in input().split()]
	min_price = min(min_price, p)
	res += a * min_price
print(res)


a = int(input())
b = [input() for i in range(a)]
costs = []
req = []
for i in b:
	costs.append(int(i.split()[1]))
	req.append(int(i.split()[0]))
min_cost = costs[0]
total = 0
i = 0
while i < a:
	if min_cost <= costs[i]:
		total += min_cost * req[i]
		i += 1
	else:
		min_cost = costs[i]
else:
	print(total)


x = input()
m = 123
t = 0
for i in range(int(x)):
	(a, b) = map(int, input().split())
	m = min(m, b)
	t = t + a * m
print(t)


N = int(input())
ret = 0
min_p = 10000000000.0
for _ in range(N):
	(a, p) = map(int, input().split())
	if p < min_p:
		min_p = p
	ret += a * min_p
print(ret)


c = 1000000
n = int(input())
v = 0
for i in range(n):
	(a, b) = map(int, input().split())
	c = min(c, b)
	v = v + a * c
print(v)


n = int(input())
(a, p) = map(int, input().split())
s = a * p
for i in range(1, n):
	(a, b) = map(int, input().split())
	if b > p:
		s += a * p
	else:
		s += a * b
		p = b
print(s)


from sys import stdin
d = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()][1:]
total = 0
min_c = d[0][1]
for (n, v) in d:
	min_c = min(min_c, v)
	total += min_c * n
print(total)


mn = 10000
cost = 0
for _ in range(int(input())):
	(i, j) = map(int, input().split())
	mn = min(mn, j)
	cost += i * mn
print(cost)


n = int(input())
meat = []
for i in range(n):
	meat.append(list(map(int, input().split())))
cost = 0
i = 0
accept = 0
while i < n:
	buy = 0
	j = i
	while j < n and meat[j][1] >= meat[i][1]:
		buy += meat[j][0]
		j += 1
	cost += buy * meat[i][1]
	i = j
	if accept == 1:
		break
print(cost)


n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
j = l[0][1]
price = 0
for i in range(n - 1):
	if j < l[i + 1][1]:
		price += j * l[i][0]
	else:
		price += j * l[i][0]
		j = l[i + 1][1]
print(price + j * l[-1][0])


n = int(input())
minimo = 101
soma = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if minimo > p:
		minimo = p
	soma += minimo * a
print(soma)


cases = int(input())
mn = float('inf')
ans = 0
while cases:
	cases -= 1
	(a, p) = map(int, input().split())
	if p < mn:
		mn = p
	ans += mn * a
print(ans)


a = []
b = []
mini = 1000
need = 0
res = 0
for _ in range(int(input())):
	lst = list(map(int, input().split()))
	need = lst[0]
	if mini > lst[1]:
		mini = lst[1]
		res += mini * need
		need = 0
	else:
		res += mini * need
		need = 0
print(res)


n = int(input())
wt = []
price = []
for i in range(n):
	(a, b) = map(int, input().split())
	wt += [a]
	price += [b]
cost = 100000000
ans = 0
for i in range(n):
	cost = min(cost, price[i])
	ans += cost * wt[i]
print(ans)


n = int(input())
lst = []
for i in range(0, n):
	data = input().split(' ')
	lst.append((int(data[0]), int(data[1])))
index = 1
result = lst[0][0] * lst[0][1]
minPrice = lst[0][1]
while index < len(lst):
	while index < len(lst) and minPrice < lst[index][1]:
		result = result + lst[index][0] * minPrice
		index = index + 1
	if index >= len(lst):
		break
	minPrice = lst[index][1]
	result = result + lst[index][0] * minPrice
	index = index + 1
print(result)


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


(m, t) = (10000000000.0, 0)
for _ in range(int(input())):
	(a, p) = map(int, input().split())
	m = min(m, p)
	t += a * m
print(t)


n = int(input())
amount = []
price = []
for i in range(n):
	(a, p) = [int(x) for x in input().split()]
	amount.append(a)
	price.append(p)
money = price[0] * amount[0]
low_price = price[0]
for i in range(1, n):
	if price[i] < low_price:
		low_price = price[i]
	money += low_price * amount[i]
print(money)


def single_integer():
	return int(input())

def multi_integer():
	return map(int, input().split())

def string():
	return input()

def multi_string():
	return input().split()
n = single_integer()
ans = 0
previous = float('inf')
for i in range(1, n + 1):
	(a, p) = multi_integer()
	if p > previous:
		ans += a * previous
	else:
		ans += a * p
		previous = p
print(ans)


n = int(input())
m = []
for i in range(n):
	(j, k) = map(int, input().split())
	m.append([j, k])
t = m[0][0] * m[0][1]
p = m[0][1]
for i in range(1, n):
	if m[i][1] > p:
		t += m[i][0] * p
	else:
		t += m[i][0] * m[i][1]
		p = m[i][1]
print(t)


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


a = int(input())
b = []
c = []
for i in range(a):
	(x, y) = map(int, input().split())
	b.append(x)
	c.append(y)
totalSpent = 0
i = 0
while i < a:
	howMuchMeat = b[i]
	x = 1
	try:
		while c[i] <= c[i + x]:
			howMuchMeat += b[i + x]
			x += 1
	except IndexError:
		pass
	totalSpent += howMuchMeat * c[i]
	i += x
print(totalSpent)


(c, f) = (0, float('inf'))
for i in range(int(input())):
	(n, m) = map(int, input().split())
	f = min(f, m)
	c += f * n
print(c)


n = int(input())
c = []
for i in range(n):
	a = list(map(int, input().split()))
	c.append(a)
l = []
r = []
for i in range(len(c)):
	l.append(c[i][0])
	r.append(c[i][1])
for i in range(n - 1):
	if r[i] < r[i + 1]:
		r[i + 1] = r[i]
z = 0
for i in range(n):
	z += r[i] * l[i]
print(z)


n = int(input())
count = 0
summa = 0
last = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if i > 0:
		if last > b:
			summa += a * b
			last = b
		else:
			summa += a * last
	else:
		summa += a * b
		last = b
print(summa)


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


a = int(input())
b = []
c = 101
s = 0
for i in range(a):
	(d, e) = map(int, input().split())
	c = min(c, e)
	s += d * c
print(s)


import math

def main_function():
	input_data = [[int(i) for i in input().split(' ')] for j in range(int(input()))]
	total = 0
	current_lowest_price = 1000000000000000000000000000000000000000000
	for i in input_data:
		(needed_meat, price) = i
		if price < current_lowest_price:
			current_lowest_price = price
		total += current_lowest_price * needed_meat
	return total
print(main_function())


a = int(input())
min = 1000000
ans = 0
for i in range(a):
	z = input().split(' ')
	if min > int(z[1]):
		min = int(z[1])
	ans += int(z[0]) * min
print(ans)


n = int(input())
(meat, cost) = ([], [])
for _ in range(n):
	(a, b) = map(int, input().split(' '))
	meat.append(a)
	cost.append(b)
total = 0
mini = 999
for i in range(n):
	if cost[i] < mini:
		mini = cost[i]
		total += mini * meat[i]
	else:
		total += mini * meat[i]
print(total)


N = int(input())
minv = 1e+20
ans = 0
for i in range(N):
	(a, p) = map(int, input().split())
	minv = min(minv, p)
	ans += a * minv
print(ans)


n = int(input())
lowest = 100
total = 0
for i in range(n):
	(a, p) = [int(x) for x in input().split()]
	lowest = min(lowest, p)
	total += lowest * a
print(total)


def sol():
	n = int(input().strip())
	[a, b] = input().split(' ')
	min_price = int(b)
	cumu_cost = int(a) * min_price
	for i in range(n - 1):
		(kg, p) = tuple(map(lambda e: int(e), input().split(' ')))
		if p < min_price:
			min_price = p
		cumu_cost += kg * min_price
	return cumu_cost
print('{0}'.format(sol()))


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
A = []
P = []
for i in range(N):
	(a, p) = map(int, input().split())
	A.append(a)
	P.append(p)
ans = 0
minCost = float('inf')
for i in range(N):
	minCost = min(minCost, P[i])
	ans += minCost * A[i]
print(ans)


a = []
ans = 0
for i in range(int(input())):
	(x, y) = map(int, input().split())
	if i == 0:
		p = y
	else:
		p = min(p, y)
	ans = ans + p * x
print(ans)


t = int(input())
l = [list(map(int, input().split())) for _ in range(t)]
s = 0
m = 1000
for i in range(t):
	if l[i][1] < m:
		m = l[i][1]
	s = s + l[i][0] * m
print(s)


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
ans = a[0][0] * a[0][1]
mi = a[0][1]
for i in range(1, n):
	if mi > a[i][1]:
		ans += a[i][0] * a[i][1]
		mi = a[i][1]
	else:
		ans += a[i][0] * mi
print(ans)


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
(r, mn) = (a[0][0] * a[0][1], a[0][1])
for i in range(1, n):
	mn = min(mn, a[i][1])
	r += mn * a[i][0]
print(r)


n = int(input())
(cnt, min_price) = (0, 101)
for i in range(n):
	x = list(map(int, input().split()))
	min_price = min(min_price, x[1])
	cnt += x[0] * min_price
print(cnt)


n = int(input())
money = 0
price = 150
for i in range(n):
	(quantity, P) = list(map(int, input().split()))
	if price > P:
		price = P
	money += price * quantity
print(money)


n = int(input())
menorP = 200
total = 0
for i in range(n):
	line = input().split(' ')
	(a, p) = (int(line[0]), int(line[1]))
	if p < menorP:
		menorP = p
	total += a * menorP
print(total)


n = int(input())
lt = []
for i in range(n):
	lt.append(list(map(int, input().split())))
s = 0
i = 0
while i < n:
	for j in range(i, n):
		if lt[j][1] >= lt[i][1]:
			s += lt[j][0] * lt[i][1]
		else:
			i = j
			break
	else:
		i = j + 1
print(s)


n = int(input())
s = 0
q = 100
for i in range(n):
	(a, p) = map(int, input().split())
	if q > p:
		s += a * p
		q = p
	else:
		s += a * q
print(s)


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


n = int(input())
m = 200
s = 0
for i in range(n):
	a = list(input().split(' '))
	m = min(m, int(a[1]))
	s += m * int(a[0])
print(s)


n = int(input())
days = []
for i in range(n):
	days.append(list(map(int, input().split())))
min_val = None
result = 0
for i in range(0, n):
	min_val = days[i][1] if not min_val else days[i][1] if days[i][1] < min_val else min_val
	result += min_val * days[i][0]
print(result)


def myaso(a, b):
	m = 10 ** 5
	c = 0
	for i in range(len(b)):
		m = min(m, b[i])
		c += a[i] * m
	return c
n = int(input())
c = list()
d = list()
for j in range(n):
	(a, p) = [int(z) for z in input().split()]
	c.append(a)
	d.append(p)
print(myaso(c, d))


t = int(input())
mc = 999998988
price = 0
for i in range(t):
	(n, m) = map(int, input().strip().split())
	mc = min(mc, m)
	price += mc * n
print(price)


n = int(input())
a = [0 for i in range(n)]
p = [0 for i in range(n)]
for i in range(n):
	(a[i], p[i]) = map(int, input().split(' '))
money = 0
minp = p[0]
for i in range(n):
	if minp <= p[i]:
		money += a[i] * minp
	else:
		minp = p[i]
		money += a[i] * minp
print(money)


def get_value():
	days = int(input())
	old_price = 101
	result = 0
	for ind in range(days):
		(meat, new_price) = [int(val) for val in input().split()]
		if old_price > new_price:
			old_price = new_price
		result += meat * old_price
	return result
print(get_value())


sum = 0
n = int(input())
(a, b) = map(int, input().split())
sum = a * b
mini = b
for i in range(n - 1):
	(a, b) = map(int, input().split())
	mini = min(mini, b)
	sum += a * mini
	mini = min(mini, b)
print(sum)


reps = int(input())
cheapest = 0
total = 0
for i in range(0, reps):
	line = [int(x) for x in input().split()]
	if i == 0 or line[1] < cheapest:
		cheapest = line[1]
	total += cheapest * line[0]
print(total)


n = int(input())
summ = 0
mini = 101
for i in range(n):
	(x, y) = map(int, input().split())
	mini = min(mini, y)
	summ += mini * x
print(summ)


n = int(input())
list_a = list()
list_p = list()
for i in range(n):
	(a, p) = str(input()).split()
	list_a.append(int(a))
	list_p.append(int(p))
value = 0
while True:
	min_p = min(list_p)
	dex = list_p.index(min_p)
	sum_a = sum(list_a[dex:])
	value += sum_a * min_p
	if dex == 0:
		break
	list_p = list_p[:dex]
	list_a = list_a[:dex]
print(value)


n_dias = int(input())
kilo_por_dia = []
preco_por_dia = []
for i in range(n_dias):
	kilos_preco = input()
	temp_array = kilos_preco.split(' ')
	kilo_por_dia.append(int(temp_array[0]))
	preco_por_dia.append(int(temp_array[1]))
preco_total = 0
menor_valor = preco_por_dia[0]
for i in range(len(preco_por_dia)):
	if menor_valor > preco_por_dia[i]:
		menor_valor = preco_por_dia[i]
	preco_total += kilo_por_dia[i] * menor_valor
print(preco_total)


n = int(input())
a = []
p = []
for i in range(n):
	temp = list(map(int, input().strip().split(' ')))
	a.append(temp[0])
	p.append(temp[1])
minp = p[0]
res = 0
for i in range(n):
	minp = min(minp, p[i])
	res += a[i] * minp
print(res)


n = int(input())
la = []
lp = []
k = 0
price = 100
for i in range(n):
	(a, p) = map(int, input().split())
	la.append(a)
	lp.append(p)
	price = min(price, lp[i])
	k = k + price * la[i]
print(k)


number = int(input())
ans = 0
mn = int(123)
for i in range(number):
	(a, b) = map(int, input().split())
	mn = min(mn, b)
	ans += a * mn
print(ans)


n = input()
a = []
b = []
for i in range(0, int(n)):
	s = input()
	mas = s.split(' ')
	a.append(int(mas[0]))
	b.append(int(mas[1]))
Sum = 0
p = 101
for i in zip(a, b):
	if i[1] < p:
		p = i[1]
	Sum += i[0] * p
print(Sum)


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


n = int(input())
prices = []
amounts = []
min_price = 1000000
for _ in range(n):
	(a, p) = map(int, input().split())
	if p < min_price:
		prices.append(p)
		amounts.append(a)
		min_price = p
	else:
		amounts[-1] += a
print(sum([a * p for (a, p) in zip(amounts, prices)]))


N = int(input())
A = []
P = []
for i in range(N):
	(a, p) = map(int, input().split())
	A.append(a)
	P.append(p)
p = 101
a = 0
for i in range(N):
	if p > P[i]:
		p = P[i]
	a += p * A[i]
print(a)


i = 0
n = eval(input())
x = [0] * 1000001
y = [0] * 1000001
while i < n:
	s = input()
	t = s.split(' ')
	x[i] = int(t[0])
	y[i] = int(t[1])
	i += 1
i = 0
while i <= n - 2:
	if y[i] < y[i + 1]:
		y[i + 1] = y[i]
	i += 1
i = 0
sum = 0
while i <= n - 1:
	sum = sum + x[i] * y[i]
	i += 1
print(sum)


n = int(input())
p = 101
answer = 0
for i in range(n):
	(ai, pi) = map(int, input().split())
	p = min(p, pi)
	answer += p * ai
print(answer)


(q, c) = ([], [])
n = int(input())
for _ in range(n):
	(a, p) = map(int, input().split())
	q.append(a)
	c.append(p)
(x, y, count) = (c[0], 0, 0)
for i in range(n):
	if c[i] < x:
		count += sum(q[y:i]) * x
		x = c[i]
		y = i
else:
	count += sum(q[y:]) * x
print(count)


n = int(input())
count = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if i == 0:
		pMin = p
	if p >= pMin:
		p = pMin
	else:
		pMin = p
	count += a * pMin
print(count)


n = int(input())
days = []
expense = 0
for i in range(n):
	days.append([int(j) for j in input().split()])
expense += days[0][1] * days[0][0]
minprice = days[0][1]
for k in range(1, n):
	if days[k][1] < minprice:
		expense += days[k][1] * days[k][0]
		minprice = days[k][1]
	else:
		expense += minprice * days[k][0]
print(expense)


n = int(input())
a = []
b = []
for i in range(n):
	line = [int(i) for i in input().split()]
	a.append(line[0])
	b.append(line[1])
money = 0
for i in range(n):
	price = min(b)
	x = b.index(price)
	money += sum(a[x:]) * price
	b = b[0:x]
	a = a[0:x]
	if b == []:
		break
print(money)


n = int(input())
(x, y) = map(int, input().split())
s = x * y
z = y
for i in range(n - 1):
	(x, y) = map(int, input().split())
	if z > y:
		z = y
	s = s + x * z
print(s)


n = int(input())
s = 0
mc = float('inf')
for _ in range(n):
	(a, p) = [int(x) for x in input().split()]
	mc = min(p, mc)
	s += mc * a
print(s)


n = int(input())
price = []
amount = []
for i in range(n):
	(a, p) = map(int, input().split())
	price.append(p)
	amount.append(a)
i = 0
total = price[0] * amount[0]
while i < n - 1:
	j = i + 1
	while j < n:
		if price[i] <= price[j]:
			total += price[i] * amount[j]
		else:
			total += price[j] * amount[j]
			break
		j += 1
	i = j
print(total)


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


def totalCost(meat, price):
	minCost = None
	total = 0
	for i in range(len(meat)):
		if minCost is None or price[i] <= minCost:
			total += meat[i] * price[i]
			minCost = price[i]
		elif price[i] > minCost:
			total += meat[i] * minCost
	return total
meat = list()
price = list()
t = int(input())
while t:
	(m, p) = [int(meat) for meat in input().split()]
	meat.append(m)
	price.append(p)
	t -= 1
val = totalCost(meat, price)
print(val)


n = int(input())
c = []
f = []
res = 0
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	f.append(a)
	c.append(b)
mini = 101
lista = []
for i in range(n):
	if c[i] < mini:
		lista.append(i)
		mini = c[i]
lista.append(n)
while len(lista) > 1:
	valor = c[lista[0]]
	comeco = lista.pop(0)
	for j in range(comeco, lista[0]):
		res += valor * f[j]
print(res)


t = int(input())
kg = []
price = []
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	kg.append(a)
	price.append(b)
total = price[0] * kg[0]
cprice = price[0]
for j in range(1, t):
	if price[j] < cprice:
		cprice = price[j]
	total += cprice * kg[j]
print(total)


dias = int(input())
price = 100
total = 0
for i in range(dias):
	(qunt, prc) = input().split(' ')
	price = min(price, int(prc))
	total += int(qunt) * price
print(total)


n = int(input())
a = []
p = []
for i in range(n):
	(ai, pi) = 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)


n = int(input())
price = 10000
sum = 0
for i in range(n):
	(a, b) = [int(a) for a in input().split()]
	if price > b:
		price = b
	sum += price * a
print(sum)


cost = 0
currMin = 10000000
for _ in range(int(input().strip())):
	(a, p) = map(int, input().strip().split())
	currMin = min(p, currMin)
	cost += a * currMin
print(cost)


n = int(input())
(m, a) = (None, 0)
for i in range(n):
	(e, c) = map(int, input().split())
	if not m:
		m = c
	else:
		m = min(m, c)
	a += e * m
print(a)


def main():
	n = int(input())
	a = [0 for _ in range(n)]
	p = [0 for _ in range(n)]
	for i in range(n):
		[ai, pi] = [int(_) for _ in input().split()]
		a[i] = ai
		p[i] = pi
	sum_money = 0
	bought = [False for _ in range(n)]
	for i in range(n):
		if not bought[i]:
			try:
				j = next((index for index in range(i + 1, n) if p[index] < p[i]))
			except StopIteration:
				j = n
			for k in range(i, j):
				sum_money += p[i] * a[k]
				bought[k] = True
	print(sum_money)
main()


n = int(input())
cmn = 101
t = 0
for i in range(0, n):
	(a, p) = map(int, input().split())
	cmn = min(cmn, p)
	t += a * cmn
print(t)


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


def Main():
	n = int(input())
	minsf = 101
	ans = 0
	for i in range(n):
		(a, p) = map(int, input().split())
		if minsf > p:
			minsf = p
		ans += minsf * a
	print(ans)
Main()


n = int(input())
a = []
p = []
s = 0
for i in range(n):
	(ar, pr) = map(int, input().split())
	a.append(ar)
	p.append(pr)
mol = p[0]
for i in range(len(a)):
	b = a[i]
	mne = p[i]
	if mne < mol:
		mol = mne
	s += b * mol
print(s)


n = int(input())
l = []
lesspi = float('inf')
price = 0
for i in range(n):
	(ai, pi) = map(int, input().split())
	if lesspi > pi:
		lesspi = pi
	price = price + ai * lesspi
print(price)


MAX_DAYS = 100000
MAX_PRICE = 100
n_days = int(input())
best_price = MAX_DAYS * MAX_PRICE
min_cost = 0
for i in range(n_days):
	(a, p) = list(map(lambda x: int(x), input().split()))
	best_price = min(best_price, p)
	min_cost += best_price * a
print(min_cost)


n = int(input())
a = []
p = []
for k in range(n):
	L = input().split(' ')
	a.append(int(L[0]))
	p.append(int(L[1]))
money = a[0] * p[0]
price = p[0]
k = 1
while k < n:
	while k < n:
		if p[k] >= price:
			money += a[k] * price
			k += 1
		else:
			break
	if k < n:
		price = p[k]
print(money)


n = int(input())
ans = 0
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append([x, y])
	if i > 0:
		a[i][1] = min(a[i - 1][1], y)
for i in range(n):
	ans += a[i][0] * a[i][1]
print(ans)


n = int(input())
lst = []
for i in range(n):
	(a, b) = map(int, input().split())
	lst.append([a, b])
m = [0, 10000000]
ans = 0
i = 0
while True and i < n:
	if lst[i][1] > m[1]:
		ans += m[1] * lst[i][0]
		i += 1
	else:
		m = lst[i]
		ans += lst[i][0] * lst[i][1]
		i += 1
print(ans)


import time
import collections

class Time_test:

	def __enter__(self):
		self.enter_time = time.time()

	def __exit__(self, exc_type, exc_val, exc_tb):
		print('Command was executed in', time.time() - self.enter_time)
n = int(input())
arr = []
for i in range(n):
	arr.append([int(x) for x in input().split()])
counter = 0
min = float('inf')
for (a, p) in arr:
	if p < min:
		min = p
	counter += a * min
print(counter)


def find_buy_days(prices):
	buy_days = []
	for (day, price) in enumerate(prices):
		if not buy_days or prices[buy_days[-1]] > price:
			buy_days += [day]
	return set(buy_days)

def calc_meat_prices(eats, prices):
	buy_days = find_buy_days(prices)
	paid = 0
	last_buy = None
	for (day, eat) in enumerate(eats):
		if day in buy_days:
			buy_days.remove(day)
			last_buy = day
		paid += prices[last_buy] * eat
	return paid

def main():
	data = [[int(n) for n in input().split()] for _ in range(int(input()))]
	print(calc_meat_prices(*list(zip(*data))))
main()


n = int(input())
result = 0
min_price = 0
for _ in range(n):
	(a, p) = [int(i) for i in input().split()]
	if _ == 0:
		min_price = p
	if p < min_price:
		min_price = p
	result += a * min_price
print(result)


def duff(ls):
	s = 0
	s = s + ls[0][0] * ls[0][1]
	k = ls[0][1]
	for i in range(1, len(ls)):
		if k > ls[i][1]:
			k = ls[i][1]
		s = s + ls[i][0] * k
	return s
n = int(input())
ls = []
while n > 0:
	ls1 = [int(i) for i in input().split()]
	ls.append(ls1)
	n = n - 1
print(duff(ls))


n = int(input())
list1 = []
list2 = []
for i in range(n):
	s = list(map(int, input().split()))
	list1.append(s[0])
	list2.append(s[1])
Sum = 0
ss = max(list2)
check = n
while True:
	if n == 0:
		break
	s = ss
	for i in range(n - 1, -1, -1):
		if list2[i] <= s:
			s = list2[i]
			n = i
			ncopy = n
	else:
		try:
			while list2[n] <= list2[ncopy]:
				if ncopy == check:
					break
				Sum += list1[ncopy] * list2[n]
				ncopy += 1
			check = n
		except:
			pass
print(Sum)


n = int(input())
cost = 0
m = float('inf')
for day in range(n):
	(a, p) = [int(x) for x in input().split(' ')]
	m = min(m, p)
	cost += a * m
print(cost)


n = int(input())
a = []
for _ in range(n):
	b = [int(x) for x in input().split()]
	a.append(b)
t = a[0][0] * a[0][1]
l = a[0][1]
for i in range(1, n):
	l = min(l, a[i][1])
	t += l * a[i][0]
print(t)


days = int(input())
(total, min_) = (0, 100)
for day in range(days):
	(a, b) = [int(x) for x in input().split()]
	if b < min_:
		min_ = b
	total += a * min_
print(total)


s = 0
m = 10000
for t in range(int(input())):
	(a, b) = map(int, input().split())
	m = min(m, b)
	s += a * m
print(s)


n = int(input())
temp = 1000
(a, b) = ([], [])
for i in range(n):
	(x, y) = [int(x) for x in input().split()]
	if y > temp:
		a.append(x)
		b.append(temp)
	else:
		a.append(x)
		b.append(y)
	temp = min(temp, y)
count = 0
for i in range(n):
	count += a[i] * b[i]
print(count)


c = 0
d = 100
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if b < d:
		d = b
	c += a * d
print(c)


n = int(input())
MIN = 101
res = 0
for i in range(n):
	(a, p) = input().split()
	(a, p) = (int(a), int(p))
	MIN = min(p, MIN)
	res += MIN * a
print(res)


n = int(input())
l1 = []
l2 = []
for i in range(n):
	j = input().split()
	l1.append(int(j[0]))
	l2.append(int(j[1]))
s = l2[0]
total = 0
for j in range(n):
	s = min(l2[j], s)
	total += l1[j] * s
print(total)


a = int(input())
mat = []
cent = 9000000
toks = 0
res = 0
for i in range(a):
	s = input().split()
	for i in range(2):
		s[i] = int(s[i])
	if s[1] < cent:
		cent = s[1]
	res += cent * s[0]
print(res)


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 = []
prev = 1000000000.0
ans = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if y < prev:
		prev = y
	ans += x * prev
print(ans)


n = int(input())
l = []
s = 0
for i in range(n):
	r = list(map(int, input().split()))
	l.append(r)
	if len(l) == 1:
		s += l[-1][0] * l[-1][1]
	elif l[-2][1] < l[-1][1]:
		l[-1][1] = l[-2][1]
		s += l[-1][0] * l[-1][1]
	else:
		s += l[-1][0] * l[-1][1]
print(s)


n = int(input())
ls = []
for i in range(n):
	(a, b) = input().split()
	ls.append(int(a))
	ls.append(int(b))
i = 1
ans = 0
m = 1000
while i < len(ls):
	m = min(m, ls[i])
	ans = ans + m * ls[i - 1]
	i = i + 2
print(ans)


n = int(input())
ans = 0
mn = 101
for _ in range(n):
	(d, m) = map(int, input().split())
	mn = min(m, mn)
	ans += d * mn
print(ans)


num_days = int(input())
total_cost = 0
lowest_so_far = float('inf')
for _ in range(num_days):
	(amount, cost) = [int(a) for a in input().strip().split()]
	if cost < lowest_so_far:
		lowest_so_far = cost
	total_cost += amount * lowest_so_far
print(total_cost)


prices = 101
cost = 0
for i in range(int(input())):
	(a, b) = map(int, input().split())
	prices = min(prices, b)
	cost += prices * a
print(cost)


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())
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)


import math
n = int(input())
a = []
p = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	p.append(y)
ans = 0
price = 1000
for i in range(n):
	price = min(p[i], price)
	ans = ans + a[i] * price
print(ans)


n = int(input())
c = 100
total = 0
for i in range(n):
	(a, p) = map(int, input().split())
	c = min(c, p)
	total += a * c
print(total)


import sys

def readline():
	return sys.stdin.readline()
t = int(readline())
sum = 0
min = 101
for x in range(1, t + 1):
	p = readline().strip().split(' ')
	p[0] = int(p[0])
	p[1] = int(p[1])
	if p[1] < min:
		min = p[1]
	sum += p[0] * min
print(sum)


n = int(input())
ans = 0
price = 10 ** 9
for i in range(n):
	(a, p) = [int(x) for x in input().split()]
	price = min(price, p)
	ans += price * a
print(ans)


n = int(input())
a = [0] * (n + 3)
p = [0] * (n + 3)
for i in range(n):
	(t1, t2) = map(int, input().split())
	a[i] = t1
	p[i] = t2
pmin = p[0]
kq = p[0] * a[0]
for i in range(1, n):
	pmin = min(pmin, p[i])
	kq += pmin * a[i]
print(kq)


n = int(input())
price = 101
money = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if p > price:
		money += a * price
	else:
		price = p
		money += a * p
print(money)


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


n = int(input())
minn = 101
ans = 0
for i in range(n):
	(a, b) = map(int, input().split())
	minn = min(minn, b)
	ans += a * minn
print(ans)


n = int(input())
s = 0
mn = 101
for _ in range(n):
	(a, p) = map(int, input().split())
	if p < mn:
		mn = p
	s += a * mn
print(s)


meat = []
price = []
for _ in range(int(input())):
	(a, p) = map(int, input().split())
	meat.append(a)
	price.append(p)
t = 99999999999999999999999999999
total = 0
for i in range(len(price)):
	if price[i] < t:
		t = price[i]
	total += meat[i] * t
print(total)


from collections import defaultdict

def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def printlist(l):
	print(''.join([str(x) for x in l]))

def listring(l):
	return ''.join([str(x) for x in l])
n = it()
a = []
p = []
for i in range(n):
	(ai, pi) = mp()
	a.append(ai)
	p.append(pi)
r = [(i, a[i]) for i in range(n)]
result = 0
j = n
while p != []:
	i = p.index(min(p))
	result += sum(a[i:j]) * p[i]
	p = p[:i]
	j = i
print(result)


n = int(input())
ans = k = 0
m = 10000000000
for i in range(n):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	if b < m:
		ans += m * k
		k = 0
		m = b
	k += a
ans += m * k
print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = [LI() for _ in range(n)]
	r = 0
	m = inf
	for (b, c) in a:
		if m > c:
			m = c
		r += m * b
	return r
print(main())


n = int(input())
(a, p) = ([], [])
for i in range(n):
	(A, P) = map(int, input().split())
	a.append(A)
	p.append(P)
(cost, final) = (p[0], 0)
for i in range(len(p)):
	cost = min(p[i], cost)
	final += cost * a[i]
print(final)


n = int(input())
best = 200
res = 0
for i in range(n):
	(a, p) = map(int, input().split())
	best = min(p, best)
	res += a * best
print(res)


n = int(input())
minimun = float('Inf')
money = 0
for i in range(0, n):
	(amountMeat, price) = [int(x) for x in input().split()]
	if price < minimun:
		minimun = price
	money += minimun * amountMeat
print(money)


x = 1000
s = int(input())
qian = 0
for i in range(s):
	(m, n) = [int(x) for x in input().split()]
	x = min(x, n)
	qian += x * m
print(qian)


n = int(input())
x = 0
y = 100
while n:
	(a, b) = map(int, input().split())
	y = min(y, b)
	x += a * y
	n -= 1
print(x)


from sys import stdin
n = int(stdin.readline())
k = 100
z = 0
res = 0
for i in range(0, n):
	(a, p) = map(int, stdin.readline().split())
	if p < k:
		res += z * k
		z = a
		k = p
	else:
		z += a
res += z * k
print(res)


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


n = int(input())
minp = 999
result = 0
for _ in range(n):
	(a, p) = map(int, input().split())
	if p < minp:
		minp = p
	result += a * minp
print(result)


n = int(input())
min_c = int(2000000000.0)
ans = 0
for i in range(n):
	(a, b) = map(int, input().split())
	min_c = min(min_c, b)
	ans += min_c * a
print(ans)


a = []
b = []
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
s = 0
r = b[0]
for i in range(0, n):
	if r >= b[i]:
		r = b[i]
	s += a[i] * r
print(s)


n = int(input())
ar = []
for _ in range(n):
	a = list(map(int, input().split()))
	ar.append(a)
count = 0
mn = 34343
for x in range(len(ar)):
	mn = min(mn, ar[x][1])
	count += ar[x][0] * mn
print(count)


n = int(input())
a = [[int(x) for x in input().split()] for i in range(n)]
sum1 = a[0][0] * a[0][1]
test = a[0][1]
for i in range(1, len(a)):
	if a[i][1] >= test:
		sum1 += test * a[i][0]
	else:
		test = a[i][1]
		sum1 += test * a[i][0]
print(sum1)


__author__ = 'pxy'
n = int(input())
minn = 1000
currentmin = 1000
g = []
need = 0
for i in range(n):
	w = [int(j) for j in input().split()]
	if minn > w[1]:
		minn = w[1]
	need = need + w[0]
	g.append(w)
t = 0
r = 0
price = 0
while r < need:
	if g[t][1] <= minn:
		price = price + g[t][1] * (need - r)
		r = r + (need - r)
	elif currentmin <= g[t][1]:
		price = price + currentmin * g[t][0]
		r = r + g[t][0]
	else:
		r = r + g[t][0]
		currentmin = g[t][1]
		price = price + g[t][0] * currentmin
	t = t + 1
print(price)


import sys
import math
input_file = sys.stdin
num_of_days = int(input_file.readline().rstrip())
meat_rec = []
for line in input_file.readlines():
	(amount, price) = map(int, line.rstrip().split())
	meat_rec.append((amount, price))
sum = 0
current_price = math.inf
for (amount, price) in meat_rec:
	if price < current_price:
		current_price = price
	sum += current_price * amount
print(sum)


n = int(input())
(a, p) = ([], [])
for i in range(n):
	(a1, p1) = input().split()
	a.append(int(a1))
	p.append(int(p1))
i = 0
s = 0
while i < n:
	j = i
	while j < n and p[i] <= p[j]:
		s += p[i] * a[j]
		j += 1
	i = j
print(s)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
answer = 0
m = inf
for _ in range(int(data())):
	(a, p) = sp()
	m = min(m, p)
	answer += a * m
out(answer)


n = int(input())
pay = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
result = 0
if n % 2 != 0:
	pay.append([0, 0])
i = 0
while i < n:
	if i < n - 1 and (pay[i][0] + pay[i + 1][0]) * pay[i][1] < pay[i][0] * pay[i][1] + pay[i + 1][0] * pay[i + 1][1]:
		result += (pay[i][0] + pay[i + 1][0]) * pay[i][1]
		j = i + 2
		while j < n and pay[i][1] < pay[j][1]:
			result += pay[i][1] * pay[j][0]
			j += 1
		i = j
	else:
		result += pay[i][0] * pay[i][1]
		i += 1
print(result)


n = int(input())
c = 10 ** 10
res = 0
for i in range(n):
	(a, p) = map(int, input().split())
	c = min(c, p)
	res += c * a
print(res)


n = int(input())
tr = [0] * n
st = [0] * n
for i in range(n):
	(tr[i], st[i]) = map(int, input().split())
(kg, p) = (0, 0)
i = 0
while i < n:
	y = i + 1
	kg = tr[i]
	while y < n and st[y] > st[i]:
		kg += tr[y]
		y += 1
	else:
		p += kg * st[i]
		i = y
print(p)


n = int(input())
b = 100
k = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if b > p:
		b = p
	k += a * b
print(k)


n = int(input())
pCur = 100
total = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if p <= pCur:
		pCur = p
	total = total + a * pCur
print(total)


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)


n = int(input())
m = 0
prize = 1000000
for i in range(n):
	(a, p) = input().split()
	(a, p) = (int(a), int(p))
	prize = min(prize, p)
	m += prize * a
print(m)


def solve(a, p, n):
	if len(a) == 0:
		return 0
	minRateSoFar = p[0]
	total = p[0] * a[0]
	for i in range(1, n):
		minRateSoFar = min(minRateSoFar, p[i])
		total += minRateSoFar * a[i]
	return total
n = int(input())
a = []
p = []
for i in range(0, n):
	(a_i, p_i) = map(int, input().split(' '))
	a.append(a_i)
	p.append(p_i)
print(solve(a, p, n))


def meat(a, p):
	ans = 0
	price = float('inf')
	for i in range(len(a)):
		price = min(price, p[i])
		ans += price * a[i]
	return ans
n = int(input())
a = []
p = []
for i in range(n):
	x = list(map(int, input().rstrip().split()))
	a.append(x[0])
	p.append(x[1])
print(meat(a, p))


n = int(input())
(ans, cscore) = (0, 1000000)
for i in range(n):
	(a, b) = map(int, input().split())
	cscore = min(cscore, b)
	ans += a * cscore
print(ans)


n = int(input())
Ai = []
Pi = []
s = 0
minP = 100
for i in range(n):
	(ai, pi) = map(int, input().split())
	Ai.append(ai)
	Pi.append(pi)
for i in range(n):
	minP = min(minP, Pi[i])
	s += Ai[i] * minP
print(s)


n = int(input())
(cnt, min_price) = (0, 0)
for i in range(n):
	x = list(map(int, input().split()))
	if i == 0:
		min_price = x[1]
		cnt = x[0] * x[1]
	else:
		if x[1] < min_price:
			min_price = x[1]
		cnt += x[0] * min_price
print(cnt)


n = int(input())
price_optimal_today = 101
total_spent = 0
for _ in range(n):
	(a, p) = map(int, input().split())
	price_optimal_today = min(p, price_optimal_today)
	total_spent += price_optimal_today * a
print(total_spent)


n_days = int(input())
p_array = []
a_array = []
pa_combined = []
purchased = {}
for n in range(n_days):
	(pi, ai) = map(int, input().split())
	p_array.append(pi)
	a_array.append(ai)
	pa_combined.append((pi, ai))
	purchased[n] = False

def get_kg_cost(pa):
	return (pa[0], pa[1])

def get_next_n(cost_today, idx):
	n = 0
	for i in range(idx, n_days):
		if cost_today <= get_kg_cost(pa_combined[i])[1]:
			n += 1
		else:
			break
	return n
total_required = sum(p_array)
total_meat = 0
total_cost = 0
for day in range(n_days):
	if not purchased[day]:
		(_, cost_today) = get_kg_cost(pa_combined[day])
		next_n = get_next_n(cost_today, day)
		for nday in range(next_n):
			purchased[day + nday] = True
			(kg, cost) = get_kg_cost(pa_combined[day + nday])
			total_cost += kg * cost_today
			total_meat += kg
			if total_meat >= total_required:
				break
print(total_cost)


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())
min_price = 101
sum = 0
for i in range(n):
	(a, p) = map(int, input().split())
	min_price = min(min_price, p)
	sum += min_price * a
print(sum)


sum = 0
z = int(input())
for i in range(z):
	c = list(map(int, input().split()))
	a = c[1]
	if i != 0:
		if b <= a:
			a = b
	sum = sum + c[0] * a
	b = a
print(sum)


n = int(input())
a = []
p = []
minp = 101
c = 0
for i in range(n):
	(a0, p0) = map(int, input().split())
	if p0 < minp:
		minp = p0
		c += a0 * p0
	else:
		c += a0 * minp
print(c)


import sys
n = int(input())
rate = sys.maxsize
total = 0
for _ in range(n):
	(a, p) = map(int, input().split())
	if p < rate:
		total += p * a
		rate = p
	else:
		total += rate * a
print(total)


n = int(input())
p = 1000
s = 0
for i in range(n):
	(x, y) = map(int, input().split())
	p = min(p, y)
	s += x * p
print(s)


n = int(input())
L = []
L1 = []
for k in range(n):
	(a, b) = map(int, input().split(' '))
	L.append(a)
	L1.append(b)
mini = 101
suma = 0
for k in range(n):
	if L1[k] < mini:
		mini = L1[k]
	suma += L[k] * mini
print(suma)


n = int(input())
a = [[int(j) for j in input().split()[:2]] for i in range(n)]
sum = 0
x = a[0][1]
p2 = 0
sum += a[0][0] * x
for i in range(1, n):
	if a[i][1] >= x:
		sum += a[i][0] * a[p2][1]
	else:
		x = a[i][1]
		p2 = i
		sum += a[i][0] * a[p2][1]
print(sum)


n = int(input())
price = 101
ans = 0
while n > 0:
	n -= 1
	(a, p) = map(int, input().split())
	if price > p:
		price = p
	ans += price * a
print(ans)


n = int(input())
ans = 0
lo = 1000
for i in range(n):
	(a, b) = map(int, input().split())
	lo = min(lo, b)
	ans += a * lo
print(ans)


n = int(input())
a = []
p = []
for i in range(n):
	b = [int(j) for j in input().split(' ')]
	a.append(b[0])
	p.append(b[1])
minp = 101
cost = 0
for i in range(n):
	if p[i] < minp:
		minp = p[i]
	cost += minp * a[i]
print(cost)


n = int(input().strip())
ll = []
t = list(map(int, input().split()))
k = t[0] * t[1]
l = t[1]
for i in range(n - 1):
	t = list(map(int, input().split()))
	if l >= t[1]:
		k = k + t[1] * t[0]
		l = t[1]
	else:
		k = k + l * t[0]
print(k)


def duff_meat():
	n = int(input())
	lista_a = []
	lista_p = []
	output = 0
	for dia in range(0, n):
		(a, p) = input().split(' ')
		lista_a.append(int(a))
		lista_p.append(int(p))
	menor = lista_p[0]
	for p in range(0, n):
		if lista_p[p] < menor:
			menor = lista_p[p]
		output += menor * lista_a[p]
	print(output)
duff_meat()


n = int(input())
l = []
for i in range(n):
	t = list(map(int, input().split()))
	l.append(t)
min = l[0][1]
cnt = 0
for i in range(n):
	if min > l[i][1]:
		min = l[i][1]
		cnt = cnt + l[i][0] * min
	else:
		cnt = cnt + l[i][0] * min
print(cnt)


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


n = int(input())
demand = []
price = []
for i in range(0, n):
	a = list(map(int, input().split()))
	demand.append(a[0])
	price.append(a[1])
t = price[0]
s = 0
for i in range(0, n):
	if price[i] < t:
		t = price[i]
	s += t * demand[i]
print(s)


T_ON = 0
DEBUG_ON = 1
MOD = 998244353

def solve():
	n = read_int()
	G = [read_ints() for _ in range(n)]
	MIN_PRICE = float('inf')
	cost = 0
	for (a, p) in G:
		MIN_PRICE = min(MIN_PRICE, p)
		cost += a * MIN_PRICE
	print(cost)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def fib_to_n(n):
	f = []
	(a, b) = (0, 1)
	while a <= n:
		f.append(a)
		(a, b) = (b, a + b)
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P

def is_lucky(n):
	return set(list(str(n))).issubset({'4', '7'})
main()


t = int(input(''))
a = [0] * t
b = [0] * t
sum = 0
for i in range(t):
	str1 = str(input(''))
	str1 = str1.split(' ')
	a[i] = int(str1[0])
	b[i] = int(str1[1])
	if i == 0:
		sum = sum + int(a[i] * b[i])
		temp = b[i]
	else:
		if b[i] < temp:
			temp = b[i]
		sum = sum + int(a[i] * temp)
print(sum)


n = int(input())
a = []
b = []
for i in range(n):
	info = list(map(int, input().split()))
	a.append(info[0])
	b.append(info[1])
ans = 0
j = 0
while j < n:
	cur = j
	ans += a[j] * b[j]
	j += 1
	while j < n and b[cur] <= b[j]:
		ans += b[cur] * a[j]
		j += 1
print(ans)


n = int(input())
M = [list(map(int, input().split())) for i in range(n)]
k = 0
mi = 100000000
for i in range(n):
	if mi > M[i][1]:
		k = k + M[i][1] * M[i][0]
		mi = M[i][1]
	else:
		k = k + mi * M[i][0]
print(k)


import sys
n = int(input())
a = 0
min_price = sys.maxsize
cur_price = 0
sum = 0
for s in range(n):
	s = input().split(' ')
	cur_price = int(s[1])
	if cur_price < min_price:
		min_price = cur_price
	a = int(s[0]) * min_price
	sum += a
print(sum)


n = int(input())
temp = [int(x) for x in input().split()]
a = temp[0]
p = temp[1]
smallest = p
counter = a * smallest
for i in range(n - 1):
	temp = [int(x) for x in input().split()]
	a = temp[0]
	p = temp[1]
	if p < smallest:
		smallest = p
	counter += a * smallest
print(counter)


n = int(input())
ai = []
pi = []
for i in range(n):
	a = list(map(int, input().split()))
	ai.append(a[0])
	pi.append(a[1])
price = 0
j = 0
while j < n:
	for k in range(j, n):
		if pi[k] >= pi[j]:
			price += pi[j] * ai[k]
			if k == n - 1:
				j = n - 1
				break
		else:
			break
	if j == n - 1:
		break
	j = k
print(price)


n = int(input())
meat = [0 for i in range(n)]
price = [0 for i in range(n)]
for i in range(n):
	(a, b) = (int(x) for x in input().split())
	meat[i] = a
	price[i] = b
minmeatcost = price[0]
cost = meat[0] * price[0]
day = 1
while day < n:
	if price[day] >= minmeatcost:
		cost = cost + meat[day] * minmeatcost
		day = day + 1
	else:
		minmeatcost = price[day]
		cost = cost + meat[day] * minmeatcost
		day = day + 1
print(cost)


n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]
cp = a[0][1]
ts = 0
for (r, p) in a:
	if p <= cp:
		ts += p * r
		cp = p
	else:
		ts += cp * r
print(ts)


n = int(input())
ap = [tuple(map(int, input().split())) for _ in range(n)]
ans = ap[0][0] * ap[0][1]
i = 1
cur = ap[0][1]
while i < n:
	while i < n and ap[i][1] > cur:
		ans += ap[i][0] * cur
		i += 1
	if i < n:
		cur = ap[i][1]
		ans += ap[i][0] * cur
		i += 1
print(ans)


n = int(input())
m = 10 * 10
s = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if m > b:
		m = b
	s += a * m
print(s)


n = int(input())
out = 0
meat = []
cost = []
for i in range(n):
	vals = [int(i) for i in input().split()]
	meat.append(vals[0])
	cost.append(vals[1])
comp = 100
for i in range(n):
	if cost[i] < comp:
		out += cost[i] * meat[i]
		comp = cost[i]
	else:
		out += comp * meat[i]
print(out)


n = int(input())
meat = [tuple(map(int, input().split())) for i in range(n)]
mm = 0
i = 0
while i < n:
	di = meat[i]
	mm += di[0] * di[1]
	for dj in meat[i + 1:]:
		if di[1] <= dj[1]:
			mm += dj[0] * di[1]
			i += 1
		else:
			break
	i += 1
print(mm)


n = int(input())
s = 0
c = float('inf')
d = []
for i in range(n):
	(a, p) = map(int, input().split())
	c = min(c, p)
	s += c * a
print(s)


x = int(input())
foodNec = []
foodCost = []
bestOption = 10000000000000000
totalCost = 0
for i in range(x):
	(a, b) = list(map(int, input().split()))
	foodNec.append(a)
	foodCost.append(b)
for j in range(len(foodCost)):
	if bestOption >= foodCost[j]:
		bestOption = foodCost[j]
	totalCost += bestOption * foodNec[j]
print(totalCost)


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


from sys import stdin
test = stdin.readlines()
n = int(test[0])
ap = [tuple(map(int, test[i].split())) for i in range(1, n + 1)]
ans = 0
min_so_far = 100
for i in range(n):
	if ap[i][1] > min_so_far:
		ans += ap[i][0] * min_so_far
	else:
		ans += ap[i][0] * ap[i][1]
		min_so_far = ap[i][1]
print(ans)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
a = [0] * t
p = [0] * t
ans = 0
prev = 100
for i in range(t):
	(a[i], p[i]) = inm()
for i in range(t):
	prev = min(prev, p[i])
	ans += a[i] * prev
print(ans)


import sys
import os.path
import functools
import itertools
import re

def solve():
	n = int(input())
	a = [0] * n
	p = [0] * n
	for i in range(n):
		(a[i], p[i]) = map(int, input().split())
	ans = 0
	i = 0
	cur = 0
	while i < n:
		cur = i
		while cur < n and p[i] <= p[cur]:
			ans += a[cur] * p[i]
			cur += 1
		i = cur
	print(ans)

def main():
	if os.path.exists('test.inp'):
		sys.stdin = open('test.inp', 'r')
	solve()
main()


n = int(input())
i = 0
ans = 0
while i < n:
	s = input().split()
	if i == 0:
		price = int(s[1])
	else:
		price = min(price, int(s[1]))
	targ = int(s[0])
	ans += targ * price
	i += 1
print(ans)


n = int(input())
m = None
t = 0
for _ in range(n):
	(w, c) = map(int, input().split())
	if m == None or m > c:
		m = c
	t += m * w
print(t)


n = int(input().strip())
A = []
P = []
for i in range(n):
	ins = input().strip().split(' ')
	(a, p) = (int(ins[0]), int(ins[1]))
	A.append(a)
	P.append(p)
total = 0
cur_min = 0
cur = 0
sub_total = 0
while cur < n:
	if P[cur_min] <= P[cur]:
		sub_total += A[cur]
		cur += 1
	else:
		total += sub_total * P[cur_min]
		sub_total = 0
		cur_min = cur
if sub_total != 0:
	total += sub_total * P[cur_min]
print(total)


n = int(input())
a = []
p = []
for i in range(0, n):
	(a1, p1) = [int(x) for x in input().split()]
	a.append(a1)
	p.append(p1)
minCurrent = 1000
cost = 0
for i in range(0, n):
	if p[i] < minCurrent:
		minCurrent = p[i]
	cost += minCurrent * a[i]
print(cost)


n = int(input())
smallest = 99999999999999
total = 0
for _ in range(n):
	(amount, price) = (int(i) for i in input().split())
	if smallest > price:
		smallest = price
	total += smallest * amount
print(total)


n = int(input())
kgs = []
price = []
for i in range(n):
	mn = list(map(int, input().split(' ')))
	kgs.append(mn[0])
	price.append(mn[1])
for i in range(0, len(kgs)):
	temp = []
	if i == 0:
		low = price[0]
		ans = kgs[0] * price[0]
	elif price[i] > low:
		ans += low * kgs[i]
	else:
		ans += kgs[i] * price[i]
		low = price[i]
print(ans)


f = lambda : map(int, input().split())
n = int(input())
(a, p) = zip(*(f() for i in range(n)))
i = 1
(w, c) = (a[0], p[0])
tc = 0
while i < n:
	if c <= p[i]:
		w += a[i]
	else:
		tc += c * w
		w = a[i]
		c = p[i]
	i += 1
print(tc + c * w)


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


n = int(input())
a = []
p = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	p.append(y)
i = 0
ans = 0
while i < n:
	start = i
	while i < n and p[start] <= p[i]:
		i += 1
	ans += sum(a[start:i]) * p[start]
print(ans)


n = int(input())
l = []
for i in range(n):
	a = [int(i) for i in input().split()]
	l.append(a)
c = 0
for i in range(n):
	if l[i][0] == 0:
		continue
	else:
		for j in range(i, n):
			if l[j][1] >= l[i][1]:
				c += l[j][0] * l[i][1]
				l[j][0] = 0
			else:
				break
print(c)


n = int(input())
a = list(map(int, input().split()))
(l, m) = (a[1] * a[0], a[1])
for _ in range(n - 1):
	a = list(map(int, input().split()))
	if a[1] < m:
		m = a[1]
		l += a[0] * m
	else:
		l += a[0] * m
print(l)


import time
n = int(input())
p0 = False
s = 0
for i in range(n):
	(a, p) = (int(i) for i in input().split())
	if p0 == False or p < p0:
		p0 = p
	s += a * p0
start = time.time()
print(s)
finish = time.time()


n = int(input())
(min_array, b) = ([10 ** 9] * n, [])
cur_min = min_array[0]
for i in range(n):
	(a, p) = map(int, input().split())
	b.append([a, p])
	if p < cur_min:
		cur_min = p
	min_array[i] = cur_min
cost = 0
for i in range(n):
	cost += min_array[i] * b[i][0]
print(cost)


n = int(input())
minimum = 999
answer = 0
for i in range(n):
	(a, p) = map(int, input().split())
	minimum = min(minimum, p)
	answer += a * minimum
print(answer)


n_days = int(input())
min = 43928647816
total = 0
for i in range(n_days):
	(a, p) = input().split(' ')
	if int(p) < min:
		min = int(p)
	total += int(a) * min
print(total)


n = int(input())
c = 0
a = [0] * n
b = [0] * n
cen = 101
c = 0
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
for i in range(n):
	cen = min(cen, b[i])
	c += a[i] * cen
print(c)


import sys
import math
input = sys.stdin.readline

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
price = []
day = []
mini = 1e+57
count = 0
n = int(input())
for _ in range(n):
	(days, cost) = int_array()
	price.append(cost)
	day.append(days)
for i in range(n):
	if price[i] < mini:
		mini = price[i]
	count += day[i] * mini
print(count)


n = int(input())
weight = []
price = []
result = 0
for _ in range(1, n + 1):
	[a, p] = [int(i) for i in input().split()]
	weight.append(a)
	price.append(p)
min_price = price[0]
for _ in range(n):
	if price[_] < min_price:
		min_price = price[_]
	result += weight[_] * min_price
print(result)


n = int(input())
(a, p) = map(int, input().split(' '))
mm = a * p
mp = p
for i in range(n - 1):
	(a, p) = map(int, input().split(' '))
	if p < mp:
		mp = p
	mm += a * mp
print(mm)


n = int(input())
lowest = -1
total_cost = 0
for _ in range(n):
	(a, p) = tuple(map(int, input().split()))
	if lowest == -1:
		lowest = p
	lowest = min(lowest, p)
	total_cost += lowest * a
print(total_cost)


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


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


n = int(input())
a = [0]
p = [0]
for i in range(n):
	f = [int(n) for n in input().split(' ')]
	a.append(f[0])
	p.append(f[1])
ans = 0
price = 99999999
i = 1
a = a[1:]
p = p[1:]
for i in range(n):
	price = min(price, p[i])
	ans = ans + price * a[i]
print(ans)


n = int(input())
a = [0] * n
for i in range(n):
	(x, y) = map(int, input().split())
	a[i] = (x, y)
now = a[0][0] * a[0][1]
min_now = a[0][1]
for i in range(1, n):
	if min_now > a[i][1]:
		min_now = a[i][1]
	now += min_now * a[i][0]
print(now)


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
(r, mn, c) = (0, float('inf'), 0)
for i in range(n):
	if a[i][1] >= mn:
		c += a[i][0]
	else:
		if c:
			r += mn * c
		c = a[i][0]
		mn = a[i][1]
print(r + mn * c)


n = int(input())
summ = 0
(need, mini) = map(int, input().split())
summ += need * mini
for i in range(n - 1):
	(need, cost) = map(int, input().split())
	if cost < mini:
		mini = cost
	summ += need * mini
print(summ)


n = int(input())
tm = 0
for i in range(n):
	(a, p) = map(int, input().split())
	if i == 0:
		mi = p
	else:
		mi = min(mi, p)
	tm = tm + a * mi
print(tm)


n = int(input())
x = []
y = []
for i in range(n):
	(a, b) = map(int, input().split())
	x.append(a)
	y.append(b)
m = 0
s = y[0]
for j in range(0, n):
	if s <= y[j]:
		m = m + x[j] * s
	else:
		s = y[j]
		m = m + x[j] * s
print(m)


n = int(input())
summ = 0
mi = 100000
for i in range(0, n):
	s = input()
	s = s.split()
	if int(s[1]) < mi:
		mi = int(s[1])
		summ = summ + int(s[0]) * mi
	else:
		summ = summ + int(s[0]) * mi
print(summ)


(x, n) = (101, 0)
for i in range(int(input())):
	(a, b) = map(int, input().split())
	x = min(b, x)
	n += a * x
print(n)


n = int(input())
r = 0
m = 2 ** 20
for _ in range(n):
	(a, p) = map(int, input().split())
	m = min(m, p)
	r += a * m
print(r)


a = []
array_1 = []
array_2 = []
m = 1000000000000000000000000000000000
result = 0
limit = int(input())
for i in range(limit):
	(x, y) = map(int, input().split())
	array_1.append(x)
	array_2.append(y)
for i in range(limit):
	if array_2[i] < m:
		m = array_2[i]
	result = result + array_1[i] * m
print(result)


sum = 0
min = 101
for _ in range(int(input())):
	(a, p) = map(int, input().split())
	if p < min:
		min = p
	sum += a * min
print(sum)


n = int(input())
A = []
for i in range(n):
	(x, y) = map(int, input().split())
	A.append((y, x))
ans = i = j = 0
while i < n:
	s = 0
	j = i
	while j < n and A[i][0] <= A[j][0]:
		s += A[j][1]
		j += 1
	ans += s * A[i][0]
	i = j
print(ans)


n = int(input())
kilogram = []
cost = []
for i in range(n):
	(a, p) = map(int, input().split())
	kilogram.append(a)
	cost.append(p)
mincost = cost[0] * kilogram[0]
for i in range(1, len(cost)):
	if cost[i - 1] < cost[i]:
		cost[i] = cost[i - 1]
	mincost += cost[i] * kilogram[i]
print(mincost)


n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
l = 10 ** 9
s = 0
for i in range(n):
	l = min(l, b[i])
	s += a[i] * l
print(s)


l = []
n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	l.append([a, b])
c = 0
for i in range(n - 1):
	if l[i + 1][1] > l[i][1]:
		l[i + 1][1] = l[i][1]
for i in range(n):
	c += l[i][0] * l[i][1]
print(c)


n = int(input())
quant = []
cost = []
for _ in range(n):
	(a, c) = map(int, input().split())
	quant.append(a)
	cost.append(c)
minCostSoFar = n * [1000000]
minCostSoFar[0] = cost[0]
for i in range(1, n):
	minCostSoFar[i] = min(cost[i], minCostSoFar[i - 1])
totPrice = sum((minCostSoFar[i] * quant[i] for i in range(n)))
print(totPrice)


def calc(x, y):
	z = y[0]
	price = 0
	for i in range(0, len(y)):
		if z <= y[i]:
			price += z * x[i]
		else:
			z = y[i]
			price += x[i] * y[i]
	print(price)
t = int(input())
x = []
y = []
for i in range(0, t):
	a = list(map(int, input().split()))
	x.append(a[0])
	y.append(a[1])
calc(x, y)


from functools import reduce
n = [int(i) for i in input().split()][0]
a = []
p = []
mins = []
for i in range(n):
	(cura, curp) = [int(i) for i in input().split()]
	a.append(cura)
	p.append(curp)
curmin = p[0]
mins = [p[0]]
for i in range(1, n):
	if p[i] < curmin:
		curmin = p[i]
	mins.append(curmin)
list_c = [i * b for (i, b) in zip(mins, a)]
product = reduce(lambda x, y: x + y, list_c)
print(product)


n = int(input())
A = []
P = []
for i in range(n):
	(a, p) = map(int, input().split())
	A += [a]
	P += [p]
s = A[0] * P[0]
mi = P[0]
for i in range(n - 1):
	if P[i + 1] < mi:
		mi = P[i + 1]
	s += A[i + 1] * mi
print(s)


n = int(input())
a = []
arr = []
for i in range(n):
	(t1, t2) = map(int, input().split())
	a.append(t1)
	a.append(t2)
	arr.append(a)
	a = []
minAmount = arr[0][1]
Amount = 0
for i in range(len(arr)):
	if arr[i][1] <= minAmount:
		minAmount = arr[i][1]
		Amount += arr[i][0] * arr[i][1]
	else:
		Amount += arr[i][0] * minAmount
print(Amount)


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


n = int(input())
data = [list(map(int, input().split())) for i in range(n)]
answer = 0
MIN = 1000
for i in range(n):
	MIN = min(MIN, data[i][1])
	answer += data[i][0] * MIN
print(answer)


n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
k = b[0]
h = 0
for i in range(n):
	if b[i] > k:
		h += k * a[i]
	else:
		k = b[i]
		h += k * a[i]
print(h)


dagen = int(input())
Aantal_Prijs = []
prijs = 0
laagsteprijs = 0
for i in range(0, dagen):
	Aantal_Prijs.append(list(map(int, input().split(' '))))
laagsteprijs = Aantal_Prijs[0][1]
for j in range(0, dagen):
	if laagsteprijs < Aantal_Prijs[j][1]:
		prijs += Aantal_Prijs[j][0] * laagsteprijs
	else:
		prijs += Aantal_Prijs[j][0] * Aantal_Prijs[j][1]
		laagsteprijs = Aantal_Prijs[j][1]
print(prijs)


d = int(input())
a = []
p = []
for _ in range(d):
	(ea, ep) = map(int, input().split())
	a.append(ea)
	p.append(ep)
kosten = 0
preis = 0
for i in range(d):
	if i == 0:
		preis = p[i]
		anz = a[i]
	elif p[i] < preis:
		kosten += anz * preis
		preis = p[i]
		anz = a[i]
	else:
		anz += a[i]
kosten += anz * preis
print(kosten)


n = int(input())
s = [[int(x) for x in input().split()] for i in range(n)]
(amount, price) = (s[0][0], s[0][1])
cost = amount * price
for i in range(1, n):
	amount = s[i][0]
	if s[i][1] < price:
		price = s[i][1]
	cost += amount * price
print(cost)


N = int(input())
a = []
p = []
min = []
for i in range(N):
	(a1, p1) = input().split()
	a.append(int(a1))
	p.append(int(p1))
min.append(p[0])
sum = min[0] * a[0]
for i in range(1, N):
	if p[i] < min[i - 1]:
		min.append(p[i])
	else:
		min.append(min[i - 1])
	sum += min[i] * a[i]
print(sum)


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


l = []
for _ in range(int(input())):
	t = list(map(int, input().split()))
	l.append(t)
(p, q, sum) = (0, 1, 0)
inif = False
inelseif = False
if len(l) == 1:
	print(l[0][0] * l[0][1])
else:
	while q <= len(l):
		if q == len(l) and inif == True:
			sum += l[p][0] * l[p][1]
			q += 1
		elif q == len(l) and inelseif == True:
			sum += l[p][1] * l[p][0]
			q += 1
		elif l[p][1] > l[q][1]:
			sum += l[p][0] * l[p][1]
			p = q
			q += 1
			inif = True
			inelseif = False
		else:
			sum += l[q][0] * l[p][1]
			q += 1
			inif = False
			inelseif = True
	print(sum)


t = int(input())
b = []
s = 0
for i in range(0, t):
	a = list(map(int, input().split()))
	b.append(a)
k = b[0][1]
for i in range(0, t):
	if k <= b[i][1]:
		s = s + b[i][0] * k
	else:
		k = b[i][1]
		s = s + b[i][0] * k
print(s)


n = int(input())
m = 99999
t = 0
for i in range(n):
	(a, p) = [int(x) for x in input().split()]
	m = min(p, m)
	t += m * a
print(t)


n = int(input())
ds = []
ps = []
for i in range(n):
	st = input()
	ap = st.split(' ')
	ds.append(int(ap[0]))
	ps.append(int(ap[1]))
res = 0
i = 0
while i < n:
	p = ps[i]
	res += p * ds[i]
	while i + 1 < n and ps[i + 1] > p:
		i += 1
		res += p * ds[i]
	i += 1
print(str(res))


days = int(input())
list1 = []
for t in range(days):
	list1.append(list(map(int, input().split())))
for p in range(len(list1)):
	if p == len(list1) - 1:
		pass
	elif list1[p][1] < list1[p + 1][1]:
		list1[p + 1][1] = list1[p][1]
	else:
		continue
results = 0
for i in range(len(list1)):
	results += list1[i][0] * list1[i][1]
print(results)


n = int(input())
m = []
p = []
for i in range(n):
	(mi, pi) = map(int, input().split())
	m.append(mi)
	p.append(pi)
ans = 0
minp = p[0]
for i in range(n):
	minp = min(p[i], minp)
	ans += m[i] * minp
print(ans)


daily_need_of_meat = []
daily_price = []
total_days = int(input())
for i in range(total_days):
	(need, price) = input().split()
	need = int(need)
	price = int(price)
	daily_need_of_meat.append(need)
	daily_price.append(price)
minimum = 120
for i in range(total_days):
	if daily_price[i] < minimum:
		minimum = daily_price[i]
	else:
		daily_price[i] = minimum
optimal = 0
for i in range(total_days):
	optimal += daily_price[i] * daily_need_of_meat[i]
print(optimal)


n = int(input())
minv = 101
ans = 0
for i in range(n):
	(ai, bi) = map(int, input().split())
	if bi < minv:
		minv = bi
	ans = ans + minv * ai
print(ans)


def get_user_input_days():
	return int(input())

def get_user_input_price():
	line_split = input().split()
	kg = int(line_split[0])
	price = int(line_split[1])
	return (kg, price)

def get_minimum_price():
	days = get_user_input_days()
	lowest_price = 100
	total = 0
	for i in range(days):
		(kg, price) = get_user_input_price()
		if price < lowest_price:
			lowest_price = price
		total += lowest_price * kg
	return total
print(get_minimum_price())


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


n = int(input())
a = []
p = []
p1 = 101
total_sum = 0
for i in range(n):
	(b, c) = input().split()
	a.append(int(b))
	p.append(int(c))
for i in range(n):
	if p[i] < p1:
		p1 = p[i]
	total_sum += a[i] * p1
print(total_sum)


n = int(input())
t = []
s = []
for j in range(n):
	(a, b) = list(map(int, input().split()))
	t.append(a)
	s.append(b)
p = 0
u = s[0]
for i in range(len(s)):
	if s[i] < u:
		u = s[i]
		p += t[i] * u
	else:
		p += t[i] * u
print(p)


n = int(input())
matrix = []
cost = 0
m = float('inf')
for i in range(n):
	(a, b) = list(map(int, input().split()))
	m = min(m, b)
	cost += a * m
print(cost)


n = int(input())
l = []
for x in range(n):
	l.append(input().split())
m = int(l[0][1])
sum = int(l[0][0]) * int(l[0][1])
for x in range(1, n):
	if int(l[x][1]) < m:
		m = int(l[x][1])
	sum += m * int(l[x][0])
print(sum)


a = int(input())
b = input().strip().split()
b[0] = int(b[0])
b[1] = int(b[1])
curM = b[1]
out = curM * b[0]
for i in range(a - 1):
	b = input().strip().split()
	b[0] = int(b[0])
	b[1] = int(b[1])
	if b[1] < curM:
		curM = b[1]
	out += curM * b[0]
print(out)


def solve(n, d):
	x = [d[0][1] for _ in range(n)]
	for i in range(1, n):
		x[i] = min(d[i][1], x[i - 1])
	s = 0
	for i in range(n):
		s += d[i][0] * x[i]
	return s

def main():
	n = int(input())
	d = [tuple(map(int, input().split())) for _ in range(n)]
	print(solve(n, d))
main()


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


n = int(input())
meat = [0] * 100002
cost = [0] * 100002
for i in range(n):
	(meat[i], cost[i]) = [int(i) for i in input().split()]
i = 0
j = 0
res = 0
while i < n:
	if i == j:
		res += meat[i] * cost[j]
		i += 1
	while cost[j] < cost[i] and i < n:
		res += meat[i] * cost[j]
		i += 1
	j = i
print(str(res))


dni = int(input())
(hmotnosti, kurzy) = ([None for i in range(dni)], [None for i in range(dni)])
for i in range(dni):
	(hmotnosti[i], kurzy[i]) = map(int, input().split())
i = 0
zaplatit = 0
while i < dni:
	(masa, kurz) = (hmotnosti[i], kurzy[i])
	i += 1
	while i < dni and kurz < kurzy[i]:
		masa += hmotnosti[i]
		i += 1
	zaplatit += masa * kurz
print(zaplatit)


mini = float('inf')
total = 0
for _ in range(int(input())):
	(a, p) = map(int, input().split())
	mini = min(mini, p)
	total += mini * a
print(total)


import sys
__author__ = 'GCA'
n = int(input())
minp = 200
total = 0
for i in range(n):
	(ai, pi) = list(map(int, input().split()))
	if pi < minp:
		minp = pi
	total += minp * ai
print(total)


import sys
input = sys.stdin.readline
n = int(input().rstrip())
(a, p) = ([], [])
for _ in range(n):
	(A, P) = map(int, input().rstrip().split())
	a.append(A)
	p.append(P)
result = 0
mini = p[0]
for i in range(n):
	if p[i] < mini:
		mini = p[i]
	result += mini * a[i]
print(result)


(minPrice, summ) = (101, 0)
for i in range(int(input())):
	(amount, price) = map(int, input().split())
	minPrice = min(minPrice, price)
	summ += amount * minPrice
print(summ)


n = int(input())
minp = 100
t = 0
output = 0
while t < n:
	(a, p) = input().split()
	minp = min(minp, int(p))
	output = output + minp * int(a)
	t = t + 1
print(output)


n = int(input())
total = 0
p_l = 100
for i in range(n):
	(a, p) = [int(j) for j in input().split()]
	if p < p_l:
		total += a * p
		p_l = p
	else:
		total += a * p_l
print(total)


n = int(input())
(Need, Price, Days) = ([0] * n, [0] * n, [0] * n)
for i in range(n):
	(a, p) = map(int, input().split())
	(Need[i], Price[i], Days[i]) = (a, p, i)
ans = 0
Price_sort = sorted(set(Price))
for j in Price_sort:
	if j in Price:
		position = Price.index(j)
		ans += j * sum(Need[position:])
		del Need[position:]
		del Price[position:]
	else:
		continue
print(ans)


z = int(input())
total = 0
min_price = 999999
while z:
	(a, b) = map(int, input().rstrip().split(' '))
	if b < min_price:
		min_price = b
	total = total + a * min_price
	z -= 1
print(total)


n = int(input())
x = 111
b = 0
for i in range(n):
	(a, p) = map(int, input().split())
	x = min(x, p)
	b += a * x
print(b)


(minPrice, price) = (100, 0)
for i in range(int(input())):
	(a, b) = map(int, input().split())
	minPrice = min(minPrice, b)
	price += a * minPrice
print(price)


quantity = int(input())
amounts = []
costs = []
for i in range(quantity):
	entry = input().split()
	amounts.append(int(entry[0]))
	costs.append(int(entry[1]))
total = 0
current_min = costs[0]
for j in range(quantity):
	if current_min > costs[j]:
		current_min = costs[j]
	total += amounts[j] * current_min
print(total)


n = int(input())
best = 101
res = 0
for i in range(n):
	nums = list(map(int, input().split()))
	best = min(best, nums[1])
	res += nums[0] * best
print(res)


n = int(input())
a = [int(i) for i in input().split()]
b = a[1]
t = a[0] * b
for _ in [0] * (n - 1):
	a = [int(i) for i in input().split()]
	if a[1] < b:
		b = a[1]
	t += a[0] * b
print(t)


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

def getMin(end, s):
	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]
	while minprice[1] < end - len(s):
		totalprice += s[minprice[1]][0] * minprice[0]
		minprice[1] += 1
	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
	a = minlist[-1].copy()
	a[2] = len(s) - 1
	minlist.append(a)
	today = 0
	totalprice = 0
	i = 0
	while i < len(minlist) - 1:
		while today < minlist[i + 1][2]:
			totalprice += minlist[i][1] * s[today][0]
			today += 1
		i += 1
	totalprice += minlist[-1][1] * s[-1][0]
	return totalprice
print(getMinFast(s))


d = int(input())
c = [[int(i) for i in input().split()] for i in range(d)]
m = [y[1] for y in c]
dd = 1
mmin = 100
x = 0
while dd <= d:
	mmin = min(mmin, m[dd - 1])
	x += mmin * c[dd - 1][0]
	dd += 1
print(x)


n = int(input())
a = []
p = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	p.append(y)
B = 0
for i in range(n):
	if a[i] != 0:
		B += a[i] * p[i]
		a[i] = 0
		for v in range(i, n):
			if p[v] >= p[i]:
				B += a[v] * p[i]
				a[v] = 0
			else:
				break
print(B)


a = int(input())
b = 101
c = 0
for i in range(1, a + 1):
	(d, e) = map(int, input().split())
	if b > e:
		b = e
	c += b * d
print(c)


n = int(input())
final_list = []
while n > 0:
	final_list.append(tuple((int(i) for i in input().split())))
	n -= 1
money = final_list[0][0] * final_list[0][1]
i = 0
while i < len(final_list):
	j = i + 1
	br = 0
	if j < len(final_list):
		while j < len(final_list):
			if final_list[j][1] > final_list[i][1]:
				money += final_list[i][1] * final_list[j][0]
				j += 1
				br = j
			else:
				i = j
				money += final_list[i][1] * final_list[i][0]
				break
	else:
		break
	if br:
		i = br
print(money)


import sys
n = int(input())
minPrice = sys.maxsize
tot = 0
for _ in range(n):
	(amnt, prc) = map(int, input().split())
	minPrice = min(prc, minPrice)
	tot += amnt * minPrice
print(tot)


import sys
from math import *
input = sys.stdin.readline

def solve(arr):
	temp = float('inf')
	tot = 0
	for i in arr:
		(a, p) = (i[0], i[1])
		temp = min(temp, p)
		tot += a * temp
	print(tot)
arr = []
for _ in range(int(input())):
	(a, p) = map(int, input().split())
	arr.append([a, p])
solve(arr)


import sys
qtyDays = int(input())
total = 0
minimumPrice = sys.maxsize
for i in range(qtyDays):
	dayStats = input().split()
	dayStats = list(map(lambda values: int(values), dayStats))
	atualPrice = dayStats[1]
	if atualPrice < minimumPrice:
		minimumPrice = atualPrice
	amount = dayStats[0]
	total += amount * minimumPrice
print(total)


def main():
	buf = input()
	n = int(buf)
	a = []
	p = []
	for i in range(n):
		buf = input()
		buflist = buf.split()
		a.append(int(buflist[0]))
		p.append(int(buflist[1]))
	cost = 0
	min_price = float('inf')
	for i in range(n):
		if p[i] < min_price:
			min_price = p[i]
		cost += a[i] * min_price
	print(cost)
main()


meat = []
price = []
for i in range(int(input())):
	(a, b) = map(int, input().split())
	meat.append(a)
	price.append(b)
meat.append(0)
price.append(0)
value = 0
for j in range(len(meat) - 1):
	value += meat[j] * price[j]
	if price[j] < price[j + 1]:
		price[j + 1] = price[j]
print(value)


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())
minMoney = 0
aux = 200
for number in range(n):
	(a, p) = map(int, input().split())
	aux = min(aux, p)
	minMoney += a * aux
print(minMoney)


d = int(input())
mp = 100
t = 0
for _ in range(d):
	(ai, pi) = map(int, input().split())
	mp = min(mp, pi)
	t += ai * mp
print(t)


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)


z = int(input())
min = 99999
count = 0
for i in range(z):
	y = list(map(int, input().split()))
	if min > y[1]:
		min = y[1]
	count += min * y[0]
print(count)


n = int(input())
(prices, days) = ([], [])
uniq_p = set()
for i in range(n):
	(a, p) = tuple((int(x) for x in input().split()))
	if p not in uniq_p:
		uniq_p.add(p)
		prices.append((p, i))
	days.append((a, i))
prices.sort(reverse=True)
out = 0
for (day, i) in reversed(days):
	out += prices[-1][0] * day
	if i == prices[-1][1]:
		while prices and prices[-1][1] >= i:
			prices.pop()
print(out)


from sys import stdin
live = True
if not live:
	stdin = open('data.in', 'r')
minPrice = 200
ans = 0
n = int(stdin.readline())
for it in range(n):
	(a, p) = list(map(int, stdin.readline().strip().split()))
	if p < minPrice:
		minPrice = p
	ans += a * minPrice
print(ans)
if not live:
	stdin.close()


z = 101
s = 0
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	z = min(z, b)
	s += a * z
print(s)


n = int(input())
dados = []
for _ in range(n):
	(a, b) = [int(x) for x in input().split()]
	dados.append((a, b))
result = 0
i = 0
while i < n:
	compra = dados[i][0]
	j = i + 1
	while j < n and dados[j][1] > dados[i][1]:
		compra += dados[j][0]
		j += 1
	result += compra * dados[i][1]
	i = j
print(result)


n = int(input())
a = n * [0]
for i in range(n):
	a[i] = list(map(int, input().split())) + [1]
f = 0
for i in range(n):
	if a[i][2]:
		j = i + 1
		while j < n and a[j][1] > a[i][1]:
			j += 1
		s = 0
		for k in range(i, j):
			s += a[k][0]
			a[k][2] = 0
		f += s * a[i][1]
print(f)


n = int(input())
li = []
cst = []
for i in range(n):
	(a, b) = map(int, input().split())
	li.append(a)
	cst.append(b)
min_cst = min(cst)
res = 0
st = False
tmp = 0
chk = 0
for i in range(n):
	if i == 0:
		tmp = cst[i]
		res += li[i] * cst[i]
		continue
	if tmp < cst[i]:
		st = True
		chk += li[i]
	elif st == True:
		res += chk * tmp
		chk = 0
		tmp = cst[i]
		res += li[i] * cst[i]
		st = True
	else:
		res += li[i] * cst[i]
		tmp = cst[i]
		chk = 0
if chk > 0:
	res += chk * tmp
print(res)


n = int(input())
minCost = -1
result = 0
for i in range(n):
	(eat, cost) = map(int, input().split(' '))
	if minCost > cost or minCost == -1:
		minCost = cost
	result += minCost * eat
print(result)


n = int(input())
a = []
p = []
for i in range(n):
	(ai, pi) = map(int, input().split(' '))
	a.append(ai)
	p.append(pi)
cur = 0
for i in range(1, n):
	if p[cur] < p[i]:
		a[cur] += a[i]
		a[i] = 0
	else:
		cur = i
r = sum((a[i] * p[i] for i in range(n)))
print(r)


import sys
n = int(input())
ap = []
for i in range(n):
	(a, p) = map(int, sys.stdin.readline().split())
	ap.append([a, p])
cost = 0
id = 0
while id < n:
	price = ap[id][1]
	while id < n and price <= ap[id][1]:
		cost += price * ap[id][0]
		id += 1
print(cost)


n = int(input())
a = []
p = []
for _ in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	p.append(y)
total = 0
current = 0
for i in range(n):
	need = a[i]
	if current < need:
		for j in range(i + 1, n):
			if p[j] < p[i]:
				break
		else:
			j = n
		need = sum(a[i:j])
		total += (need - current) * p[i]
		current = need - a[i]
	else:
		current = current - need
print(total)


days = int(input())
dados = []
for _ in range(days):
	(need, price) = [int(x) for x in input().split()]
	dados.append((need, price))
amount = 0
i = 0
while i < days:
	compra = dados[i][0]
	j = i + 1
	while j < days and dados[j][1] > dados[i][1]:
		compra += dados[j][0]
		j += 1
	amount += compra * dados[i][1]
	i = j
print(amount)


n_input = int(input())
n_min = 101
result = 0
for i in range(n_input):
	(a, p) = map(int, input().split(' '))
	if p < n_min:
		n_min = p
	result += a * n_min
print(result)


n = int(input())
L = [list(map(int, input().split())) for _ in range(n)]
T = [0 for _ in range(n)]
T[0] = L[0][1]
for i in range(1, n):
	T[i] = min(L[i][1], T[i - 1])
r = 0
for i in range(n):
	r += T[i] * L[i][0]
print(r)


t = int(input())
sum1 = 0
price = 10100101010101
for i in range(t):
	(a, p) = map(int, input().split(' '))
	price = min(price, p)
	sum1 += a * price
print(sum1)


lst1 = []
lst2 = []
for a in range(int(input())):
	lst = [int(x) for x in input().split()]
	lst1.append(lst[0])
	lst2.append(lst[1])
cost = lst1[0] * lst2[0]
q = lst2[0]
for i in range(1, len(lst2)):
	if q < lst2[i]:
		cost += q * lst1[i]
	else:
		q = lst2[i]
		cost += q * lst1[i]
print(cost)


def greddy(n):
	minimum_price = 101
	sum_ = 0
	for i in range(n):
		(a_i, p_i) = map(int, input().split())
		if p_i < minimum_price:
			minimum_price = p_i
		sum_ += a_i * minimum_price
	return sum_
n = int(input())
print(greddy(n))


n = int(input())
p = 100
ans = 0
while n:
	(a, b) = map(int, input().split())
	p = min(p, b)
	ans += a * p
	n -= 1
print(ans)


n = int(input())
i = 0
a = []
p = []
while i < n:
	s = input().split()
	a.append(int(s[0]))
	p.append(int(s[1]))
	i += 1
i = 0
out = 0
while i < n:
	x = a[i]
	j = i
	t = i
	while i != n - 1 and p[t] < p[i + 1]:
		x += a[i + 1]
		j = i
		i += 1
	if i != n - 1 and p[t] >= p[i + 1]:
		out = out + x * p[t]
		i += 1
		continue
	if i == n - 1:
		out = out + x * p[t]
		i += 1
		continue
print(out)


n = int(input())
a = [0] * n
p = [0] * n
for i in range(n):
	(a[i], p[i]) = tuple(map(int, input().split()))
res = 0
goodprice = p[0]
for i in range(n):
	if goodprice > p[i]:
		goodprice = p[i]
	res += a[i] * goodprice
print(res)


n = int(input())
c = 0
(a, b) = map(int, input().split())
c += a * b
minn = b
for i in range(0, n - 1):
	(a, b) = map(int, input().split())
	if b < minn:
		minn = b
	c += a * minn
print(c)


n = int(input())
(a, p) = ([], [])
for i in range(0, n):
	(x, y) = map(int, input().split())
	a.append(x)
	p.append(y)
(i, ans) = (0, 0)
while i < n:
	(j, tmp) = (i, 0)
	while j < n and p[j] >= p[i]:
		tmp += a[j]
		j += 1
	ans += tmp * p[i]
	i = j
print(ans)


n = int(input())
amount = []
money = []
ans = 0
for i in range(n):
	line = [int(x) for x in input().split()]
	amount.append(line[0])
	money.append(line[1])
for i in range(n - 1):
	if money[i] <= money[i + 1]:
		money[i + 1] = money[i]
for i in range(n):
	ans += amount[i] * money[i]
print(ans)


n = int(input())
(A, P) = ([], [])
(a, p) = map(int, input().split())
A.append(a)
P.append(p)
(minp, minindexes) = (p, [0])
for i in range(1, n):
	(a, p) = map(int, input().split())
	A.append(a)
	P.append(p)
	if p < minp:
		minp = p
		minindexes.append(i)
cost = 0
for i in range(len(minindexes) - 1):
	index = minindexes[i]
	nextindex = minindexes[i + 1]
	cost += sum(A[index:nextindex]) * P[index]
cost += sum(A[minindexes[-1]:]) * P[minindexes[-1]]
print(cost)


n = int(input())
aipi = []
for x in range(n):
	(a, b) = map(int, input().split())
	aipi.append([a, b])
start_day = 0
total = 0
while start_day < len(aipi):
	total += aipi[start_day][0] * aipi[start_day][1]
	next = start_day + 1
	while next < len(aipi) and aipi[next][1] > aipi[start_day][1]:
		total += aipi[next][0] * aipi[start_day][1]
		next += 1
	start_day = next
print(total)


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())
(a, kilo) = map(int, input().split())
s = kilo * a
while n - 1 > 0:
	(a, b) = map(int, input().split())
	if b < kilo:
		kilo = b
	s += kilo * a
	n -= 1
print(s)


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


n = int(input())
p = 100
ans = 0
for i in range(n):
	(a, b) = map(int, input().split())
	p = min(p, b)
	ans = ans + p * a
print(ans)


__author__ = 'suvasish'
req_meat = cost = 0
day = []
meat = []
n = int(input())
for tc in range(0, n):
	t = list(map(int, input().split(' ')))
	day.insert(tc, t[0])
	meat.insert(tc, t[1])
if n == 1:
	cost += day[0] * meat[0]
else:
	p = 0
	while p < len(meat):
		if p == len(meat) - 1:
			cost += day[p] * meat[p]
			break
		ind_low = p
		req_meat += day[p]
		for q in range(p + 1, len(meat)):
			if meat[q] < meat[p]:
				ind_low = q
				break
			req_meat += day[q]
			if q == len(meat) - 1:
				cost += req_meat * meat[p]
				print(cost)
				exit(0)
		req_meat = 0
		for i in range(p, ind_low):
			cost += day[i] * meat[p]
		p = ind_low
print(cost)


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


n = int(input())
A = []
P = []
for i in range(n):
	(a, p) = map(int, input().split())
	A.append(a)
	P.append(p)
mn = 142
ans = 0
for i in range(n):
	mn = min(mn, P[i])
	ans += A[i] * mn
print(ans)


n = int(input())
cost = 0
a = []
mini = 0
for i in range(n):
	(x, y) = map(int, input().split())
	a.append([x, y])
for i in range(n):
	if i == 0:
		cost += a[i][1] * a[i][0]
		mini = a[i][1]
	elif a[i][1] >= mini:
		cost += a[i][0] * mini
	else:
		mini = a[i][1]
		cost += a[i][0] * mini
print(cost)


n = int(input())
m = 1000
c = 0
for i in range(1, n + 1):
	(a, b) = map(int, input().split())
	m = min(m, b)
	c += a * m
print(c)


arr = []
for i in range(int(input())):
	(a, b) = map(int, input().split())
	arr.append((a, b))
i = 0
s = 0
price = arr[0][1]
while i < len(arr):
	if price * arr[i][0] > arr[i][1] * arr[i][0]:
		price = arr[i][1]
	s += price * arr[i][0]
	i += 1
print(s)


from typing import List, Tuple

def parse_input() -> Tuple[int, List[List[int]]]:
	n = int(input())
	arr = [[int(x) for x in input().split()] for _ in range(n)]
	return (n, arr)

def solve(n: int, arr: List[List[int]]) -> int:
	total_cost = arr[0][0] * arr[0][1]
	min_price = arr[0][1]
	for elem in arr[1:]:
		min_price = min(min_price, elem[1])
		total_cost += elem[0] * min_price
	return total_cost
(n, arr) = parse_input()
print(solve(n, arr))


n = int(input())
butuh = []
harga = []
for i in range(n):
	(x, y) = map(int, input().split())
	butuh.append(x)
	harga.append(y)
total = 0
while len(butuh) > 0:
	h = min(harga)
	ind = harga.index(h)
	total += h * sum(butuh[ind:])
	butuh = butuh[:ind]
	harga = harga[:ind]
print(total)


from collections import *
import sys
import math
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input())

def stli():
	return [int(i) for i in input().rstrip('\n')]
tot = 0
l = []
for _ in range(val()):
	l.append(li())
mi = min((i[1] for i in l))
i = 0
while i < len(l):
	j = i
	while j < len(l) and l[j][1] >= l[i][1]:
		tot += l[i][1] * l[j][0]
		j += 1
	i = j - 1
	i += 1
print(tot)


n = int(input())
sumy = 0
(a, b) = map(int, input().split())
small = b
sumy += a * small
for i in range(n - 1):
	(a, b) = map(int, input().split())
	if b < small:
		small = b
	sumy += a * small
print(sumy)


n = int(input())
(a, p) = ([0 for i in range(n)], [0 for i in range(n)])
k = 0
for i in range(n):
	(a[i], p[i]) = map(int, input().split())
r = p.index(min(p))
while r >= 0:
	k += p[r] * sum(a[r:])
	a = a[:r]
	if r == 0:
		break
	r = p[:r].index(min(p[:r]))
print(k)


import sys
import math
n = int(input())
mi = 100
ans = 0
for _ in range(n):
	(a, p) = map(int, input().split())
	mi = min(mi, p)
	ans += a * mi
print(ans)


import sys
n = int(input())
a = [0] * n
p = [0] * n
for i in range(n):
	(a[i], p[i]) = map(int, sys.stdin.readline().split())
restL = n
ans = 0
while restL > 0:
	pMin = min(p[:restL])
	idx = p.index(pMin)
	ans += p[idx] * sum(a[idx:restL])
	restL = idx
print(ans)


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


n = int(input())
maximo = 100000
custo = 0
for d in range(n):
	(a, p) = input().split()
	if int(p) < maximo:
		maximo = int(p)
	custo += maximo * int(a)
print(custo)


money = 0
cost = 101
days = int(input())
while days > 0:
	days = days - 1
	line = input().split(' ')
	x = int(line[0])
	y = int(line[1])
	if cost > y:
		cost = y
	money += cost * x
print(money)


X = int(input())
(a, b) = list(map(int, input().split()))
Max = b
count = a * Max
for _ in range(X - 1):
	(a, b) = list(map(int, input().split()))
	if b < Max:
		Max = b
		count += Max * a
	else:
		count += Max * a
print(count)


inp = input()
n = int(inp)
a = []
p = []
money = 0
min_pi = 1000
for i in range(n):
	chars = input().split()
	ai = int(chars[0])
	pi = int(chars[1])
	if pi < min_pi:
		min_pi = pi
	money = money + ai * min_pi
print(money)


n = int(input())
demand = []
price = []
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	demand.append(a)
	price.append(b)
money = 0
while len(price) > 1:
	s = min(price)
	d = price.index(s)
	if d != 0:
		l = demand[d:len(price)]
		su = sum(l)
		money += s * su
		price = price[0:d]
	else:
		l = demand[1:len(price)]
		su = sum(l)
		money += s * su
		break
money += demand[0] * price[0]
print(money)


n = input()
t = 999
sum = 0
for i in range(int(n)):
	(a, b) = map(int, input().split())
	t = min(t, b)
	sum = sum + a * t
print(sum)


n = int(input())
mini = 101
s = 0
for i in range(n):
	(a, p) = [int(i) for i in input().split()]
	mini = min(mini, p)
	s += mini * a
print(s)