LearnPy Hub
← Arena
IntermediateRating 1400

Cut the Rod

A rod of length n can be cut into pieces; price[i] is the price of a piece of length i (1-based). Print the maximum revenue.

Input

n, then n prices.

Output

A number.

Sample 1

Input
8
1 5 8 9 10 17 17 20
Output
22

Sample 2

Input
1
3
Output
3
solution.py
Output appears here
Cut the Rod · Python Arena problem · LearnPy Hub