Олимпиадный тренинг

Задача 38702. List of Sergei Nikolaevich - 2


Sergey Nikolaevich likes to study statistics. At his disposal came across a list of the growth of all the students of the lyceum. To his chagrin, all the data was written in random order and, moreover, took up several pages. Having learned the height of the tallest and shortest of the students, Sergei Nikolaevich began to look for these data on the list. It takes 1 millisecond to read one record. Determine how many milliseconds it will take for Sergey Nikolaevich to find records of the highest and lowest students. If there are several such students, Sergey Nikolaevich takes the first one he meets.

Input
The first line contains the number N - the number of people in the list (1<N<=105). The second line contains N numbers - growth of people in the list (each number in the range from 100 to 220).

Imprint
Print a single number on the screen - the number of milliseconds that Sergey Nikolayevich will need to find the required records.
 
Examples
# Input Output
1
10
112 136 165 205 122 116 177 212 107 169  
9