eolymp
bolt
Try our new interface for solving problems
Problems

The Fair Nut and Rectangles

The Fair Nut and Rectangles

The Fair Nut got stacked in planar world. He should solve this task to get out.

You are given n rectangles with vertexes in (0, 0), (xi, 0), (xi, yi), (0, yi). For each rectangle, you are also given a number ai. Choose some of them that the area of union minus sum of ai of the chosen ones is maximum.

It is guaranteed that there are no nested rectangles.

Nut has no idea how to find the answer, so he asked for your help.

Input

The first line contains one integer n (1n106) - the number of rectangles.

Each of the next n lines contains three integers xi, yi and ai (1xi, yi109, 0aixi * yi).

It is guaranteed that there are no nested rectangles.

Output

Print the answer to the problem - the maximum value which you can achieve.

prb11364.gif

Time limit 1 second
Memory limit 128 MiB
Input example #1
3
4 4 8
1 5 0
5 2 10
Output example #1
9
Input example #2
4
6 2 4
1 6 2
2 4 3
5 3 8
Output example #2
10