#K2116. Maximum New Flags

    ID: 24666 Type: Default 1000ms 256MiB

Maximum New Flags

Maximum New Flags

You are given an integer n representing the number of days and a list of n integers representing the maximum altitudes reached on each day. On each day, if the altitude has not been reached before, a new flag is planted. Your task is to compute the total number of new flags planted over the n days.

The answer is essentially the count of distinct altitudes. Formally, if the altitudes are given by \(a_1, a_2, \dots, a_n\), then the result is:

[ \text{Result} = |{a_1, a_2, \dots, a_n}|, ]

Input is taken from standard input and output should be printed to standard output.

inputFormat

The first line contains a single integer n (number of days). The second line contains n space-separated integers representing the maximum altitudes reached on each day.

Example:

5
1 2 3 2 4

outputFormat

Output a single integer which is the total number of new flags planted (i.e. the number of distinct altitudes).

Example:

4
## sample
5
1 2 3 2 4
4

</p>