Joe and Bob are bus drivers, both working for the same company and driving the same route. Joe and Bob's bus route can be modeled as a line of
If both Joe and Bob arrive at a stop at the same time, Bob will pick up the passengers (because Joe is a meanie). Furthermore, only one driver can pick up passengers from a stop at a time: if the other driver reaches that stop, they simply go past.
Joe is competitive and wants to beat Bob to the last station by the greatest amount of time possible. Joe, being devious, has decided that if necessary he will stop for an arbitrary number of seconds between stops in order to allow Bob to pick up passengers at the next stop. Joe wishes to know the maximum time by which he can beat Bob; that is, the largest possible number of seconds between their arrivals at the last station.
Constraints
Input Specification
The first line of input will contain a single integer
Output Specification
Output on a single line the greatest number of seconds by which Joe can beat Bob, or
Sample Input
9
5 3 9 6 1 3 8 1 3
Sample Output
4
Comments