A desk must liquidate n positions. It can liquidate only one position at a time; liquidating position i occupies the desk for t_i minutes. Every position bleeds money while it is still on the book: position i costs c_i dollars per minute until the minute its liquidation is complete.
The desk starts at minute 0 and never idles. Choose the liquidation order that minimizes the total bleed, and output that minimum total cost.
The first line contains the integer n. Each of the next n lines contains two integers t_i and c_i.
One integer: the minimum total cost.
1 <= n <= 10000
1 <= t_i, c_i <= 1000
This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.
2 1 10 10 1
21
3 3 7 5 2 2 9
73