A. Mountain Climbing
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Example
Input
5
2 5 3 4 1
Output
17