n = int(input())
d = {}
s = 0
time = 0
for _ in range(n):
a, b = map(int, input().split())
d[b / a] = d.get(b / a, []) + [(a, b)]
d = dict(sorted(d.items(), key=lambda x: x[0], reverse=True))
for i in d:
for used_time, rate in d[i]:
s += time * rate
time += used_time
print(s)
找规律?按融化速度和搬运时间的比值排序,搬运过程中不计入融化