#P8003. 赶吃花的牛

赶吃花的牛

题目描述

农夫JohnJohn出去砍伐,让NN头牛在草地上吃草。当他回来时吃惊的看到这些牛全部都跑到花园里在吃他的美丽花朵。他立即去把每头牛赶回它的牛栏。

ii号牛每分钟要吃掉DiD_i朵花,距离自己的栏地要TiT_i分钟路程。不幸的是JohnJohn每次只能赶一头牛回栏,再回到花园。请问这些牛最少要吃掉多少朵花?

输入格式

第一行一个数N。

下面NN行,每行两个数TiT_i DiD_i,表示第i头牛的数据。

输出格式

一个整数,最少吃掉的花朵数。

样例

input

6
3 1
2 5
2 3
3 2
4 1
1 6

output

86

注释

说明:最好方案赶回牛的次序为 6,2,3,4,1,5

FJ returns the cows in the following order: 6, 2, 3, 4, 1, 5. While he is transporting cow 6 to the barn, the others destroy 24 flowers; next he will take cow 2, losing 28 more of his beautiful flora. For the cows 3, 4, 1 he loses 16, 12, and 6 flowers respectively. When he picks cow 5 there are no more cows damaging the flowers, so the loss for that cow is zero. The total flowers lost this way is 24 + 28 + 16 + 12 + 6 = 86.

限制与提示

###数据范围

2N100,0002 \leq N \leq 100,000

1Ti2,000,0001 \leq T_i \leq 2,000,000

1Di1001 \leq D_i \leq 100