Problem B
Dirty Driving

Like all other good drivers, you like to curse, swear and honk your horn at your fellow automobile drivers. Today you’re at the rear of a long line, brooding over the others’ inability to keep proper distance to the car in front. But are you really keeping your own distance?
You have calculated that in order to never have to use your
breaks, you must keep a distance to any car
Given the value of
Input
First a line with
Then a single line with
Output
The minimum distance you must keep to the car directly in front, in order to not have to use your breaks.
Sample Input 1 | Sample Output 1 |
---|---|
3 1 1 2 4 |
1 |
Sample Input 2 | Sample Output 2 |
---|---|
6 3 2 3 4 5 6 1 |
13 |