LearnPy Hub
← Arena
IntermediateRating 1200

Down the Triangle

A number triangle has n rows; row i has i numbers. Start at the top and move down to one of the two numbers below each time. Print the smallest possible sum of a path to the bottom.

Input

n, then n rows.

Output

One integer.

Sample 1

Input
4
2
3 4
6 5 7
4 1 8 3
Output
11

Sample 2

Input
1
-10
Output
-10
solution.py
Output appears here
Down the Triangle · Python Arena problem · LearnPy Hub