The Triangle#3189

The Triangle

1 second
122.174 megabytes
Medium
prb3189

A triangle of numbers is shown in the figure. Write a program that calculates the greatest sum of numbers along a path that begins at the top of the triangle and ends at its base.

Input

The first line contains the number of rows in the triangle.

The following lines describe the triangle itself, with numbers in each line separated by spaces.

Output

Print the greatest sum on a path from the top to the base of the triangle.

Examples

Example 1

Loading
Loading