An election was held today. A total of n parties, numbered 1 through n, has participated in this election, and m slots were distributed among the parties based on the number of votes each party got. The following algorithm was used for slot distribution:
Suppose that the parties 1,2,…,n got c_1,c_2,…,c_n votes, respectively. Let s=c_1+c_2+…+c_n. First, for each i, ⌊sc_i⋅m⌋ slots are distributed to the party i. Then, the remaining slots are distributed from the parties with the larger value of the fractional part of sc_i⋅m, one slot per party. In case of a tie, the lower-indexed party has the priority.
You have the following information:
Compute the minimum possible number of total slots m.
The first line of input contains one integer n (1≤n≤100). Then n lines follow, each contains a pair of integers a_i and b_i (1≤a_i≤1000, 0≤b_i≤109). You may assume that there exists at least one i such that b_i≥1.
Print the minimum possible number of total slots m.