#K39737. Maximum Transaction Duration

    ID: 26487 Type: Default 1000ms 256MiB

Maximum Transaction Duration

Maximum Transaction Duration

You are given a list of integer timestamps representing the seconds at which transactions were completed during a day. Each transaction takes exactly one second. If two or more transactions occur at the same second, they are overlapping and can only be counted as one non-overlapping transaction. Your task is to compute the maximum total duration of non-overlapping transactions, which is equal to the number of unique timestamps.

In mathematical terms, given a list \( T = [t_1, t_2, \ldots, t_n] \), the result is:

\[ \text{result} = \left| \{ t_i : 1 \le i \le n \} \right| \]

For example, if the input is 1 3 2 4 5 6 10, the answer is 7 since there are 7 unique timestamps.

inputFormat

The first line of the input contains a single integer \( n \) (\( 0 \le n \le 10^6 \)), representing the number of transactions. The second line contains \( n \) space-separated integers, each representing a transaction timestamp in seconds.

outputFormat

Output a single integer representing the maximum total duration of non-overlapping transactions (i.e. the number of unique timestamps).

## sample
7
1 3 2 4 5 6 10
7