Gathering Mushrooms

No attempts yetTime limit1sMemory limit128 MB

Problem

Many kinds of mushrooms grow in the forest of Byteland. Recently a famous mushroom picker, Mr. Stanislaw, discovered a delicious new species and named it the Stasiek.

A Stasiek is special because you can easily predict how much its weight grows each day. Unfortunately, every mushroom turns poisonous after a certain number of days and can no longer be eaten. Fortunately, Mr. Stanislaw can tell, just by looking at a mushroom, after how many days it will become inedible.

Today Mr. Stanislaw walked through the forest and wrote down the data of every mushroom he saw. Now he wonders after how many days he should come back in order to collect as much mushroom weight as possible. If several days are equally good, he always picks the earliest one. His wife also forbids him from visiting the forest twice in one day, so he cannot come back after 00 days (that is, today).

Each mushroom ii weighs mim_i today (day 00) and its weight grows by pip_i every day. The mushroom stays edible for did_i days counting from today, that is on days 0,1,,di10, 1, \dots, d_i - 1, and becomes poisonous on day did_i. Therefore, if Mr. Stanislaw comes back on a day t1t \ge 1, only the mushrooms with t<dit < d_i are edible, and such a mushroom then weighs mi+pitm_i + p_i \cdot t.

On the day he returns, Mr. Stanislaw collects the total weight of every mushroom that is still edible. Find the day t1t \ge 1 that maximizes this total weight. If several days give the maximum, the answer is the earliest of them.

Input

The first line contains the number of mushrooms nn (1n1061 \le n \le 10^6).

Each of the next nn lines describes one mushroom with three space-separated integers mm, pp, dd (1m,p,d1051 \le m, p, d \le 10^5): the current weight, the daily weight gain, and the number of days the mushroom stays edible, respectively.

Output

Print a single integer on one line: the number of days after which Mr. Stanislaw should return so that the collected mushroom weight is as large as possible. If the maximum is reached on several days, print the earliest one.

Note

Suppose there are three mushrooms with (m,p,d)=(1,1,2)(m, p, d) = (1, 1, 2), (5,5,3)(5, 5, 3), (7,2,4)(7, 2, 4). The total weight of the edible mushrooms on each possible return day is:

  • after 11 day: the three mushrooms weigh (2,10,9)(2, 10, 9), summing to 2121;
  • after 22 days: the first mushroom is poisonous and cannot be eaten, the remaining two weigh (15,11)(15, 11), summing to 2626;
  • after 33 days: only the third mushroom is edible, weighing 1313;
  • after 44 days: no mushroom is edible, so the sum is 00.

The total weight of edible mushrooms is largest, 2626, after 22 days, so the answer is 22.