New issue
An unexpected inspection is taking place at the "Olenyatko" camp, where the LKS is being held this year. With each new inspection, the requirements for the camp and its participants become increasingly peculiar. Previously, it was mainly the students and teachers who bore the brunt of these changes, but now it has affected me as well. The new inspectors were displeased that during exercises, children of significantly different heights were standing next to each other. Now, I need to find a way to address this issue. Fortunately, the junior teachers helped me come up with an algorithm to rearrange the students, and all that's left is to implement it.
During exercises, all the children stand in a single line. According to the algorithm, the first step is to identify the tallest and shortest students who are standing closest to each other and calculate the distance between them. I thought about it and managed to solve this problem. Can you do it too?
Input
The first line of the input file contains the number N (1 ≤ N ≤ 10^5) - the number of students during exercises. The next line contains N non-negative integers separated by spaces, each representing the height of a student in centimeters. Some students may have the same height, but none are taller than 10^9 centimeters.
Output
In the output file, print a single number - the distance between the tallest and the shortest students who are standing closest to each other.
Notes to examples
In the first example, the tallest student is the fifth, and the shortest is the third, so the distance between them is 2.
In the second example, there are several tallest and shortest students, and the minimum distance between them is 1, as between the first and second students, for example.