Mathematical platforms
In older games, which have 2D graphics, one can run into the next situation. The hero jumps along the platforms or islands that hang in the air. He must move himself from one side of the screen to the other. The hero can jump from any platform number to any platform number , spending energy, where and are the heights where these platforms hang. Obviously energy should be spent frugally.
You are given the heights of the platforms in order from the left side to the right. Can you find the minimum amount of energy to get from the -st (start) platform to the -th (last)?
Input
The first line contains the number of platforms . The second line gives integers — the heights of the platforms, which absolute values are not greater than .
Output
Print the singe integer which is the minimum amount of energy to get from the -st platform to the -th.