Lotus leaf pond has n line, a frog jump on it and it every jump, only from a lotus leaf to adjacent lotus leaves, and it between two pieces of lotus leaf, only jump time limited, the frog can from any lotus leaf, ask it at most how many times can jump,
The input description
The first conduct an integer n, said lotus leaf number,
Second behavior n - 1 integers, the case of integers I said in the I and the I + 1 between the lotus leaf, the frog
Jump at most how many times (from left to right, or from right to left, are included),
The output shows that
An integer, the number of jumping frog jumps up,
The input sample
5
2 1 2 1
The output sample
5
This is a in anhui province this year's topic, you can give me a idea or code?
thank you