- Time limit: 1.00 s
- Memory limit: 512 MB
A hungry frog is going to hunt flies. It has stationed itself on one side of a pond that has rocks in it numbered . On the -th rock there are flies flying around it. From the -th rock the frog can jump forward to any of the rocks between and inclusive. Find the maximum number of flies the frog can catch. Initially, the frog can jump on to any of the rocks.
Input
The first line contains a single integer . The -th of next following lines contains three integers , , and .
Output
Print the maximum number of flies the frog can catch.
Constraints
Example 1
Input:
4 9 1 1 11 2 4 13 3 3 19 4 4
Output:
30
Example 2
Input:
10 19 8 10 7 2 3 5 4 10 4 4 6 14 7 7 11 7 10 7 8 10 5 9 10 5 9 10 14 10 10
Output:
61