~/algor $ cat problems/minmax-20-ekstremal-elementlar-soni
Number of extreme elements
Easy
1000 ms
256 MB
28%
A positive integer $N$ and $N$ integers are given. Count the total number of extreme elements of the sequence (that is, equal to the minimum or the maximum value).
Input
The first line contains an integer $N$. The next line contains $N$ integers $A_{i}$.
Output
One integer — the total number of extreme elements.
Note
$1 \le N \le 1000$
$-10^{9} \le A_{i} \le 10^{9}$
Examples
Input #1
6 2 8 2 5 8 2
Output #1
5
Input #2
4 5 5 5 5
Output #2
4