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

Задача 27037. not equal to the maximum


Given a set of N integers. It is necessary to determine the number of elements that have values ​​that are not equal to the value of the maximum element from this set.

Write a time and memory efficient program to solve this problem. The program is considered efficient in time if the increase in the number of initial numbers N by k times increases the running time of the program by no more than k times. A program is considered memory efficient if the memory required to store program variables does not exceed one kilobyte and does not increase with increasing N.
 
Input
The first line of the input specifies the number of numbers N (\(1 <= 𝑁 <=100 000\)). In each of the subsequent 𝑁 lines contains one integer not exceeding 1000 modulo.
 
Output
Output one number - the answer to the problem
 

 

Examples
# Input Output
1
5
7
-5
9
8
9
3

In the given set of 5 numbers, there are three elements — 7, –5 and 8, whose values ​​are not equal to the value of the maximum element of this set — 9.