#K43957. Beauty of Sequence

    ID: 27424 Type: Default 1000ms 256MiB

Beauty of Sequence

Beauty of Sequence

You are given a sequence of integers. The beauty of the sequence is defined as the maximum number of distinct integers found in any of its contiguous subarrays. In other words, for every contiguous subarray of the given sequence, count the number of distinct elements and the answer is the maximum of these counts.

For example, consider the sequence [1, 2, 1, 3, 2]. Its contiguous subarrays include [1], [1,2], [1,2,1], [1,2,1,3], etc. The subarray [1,2,1,3] has 3 distinct elements (1, 2, 3), so the beauty of the sequence is 3.

Constraints:

  • $1 \le n \le 100$
  • $0 \le a_i \le 1000$ for each element $a_i$ in the sequence.

inputFormat

The input is given via standard input (stdin) and consists of two lines. The first line contains a single integer $n$, representing the number of elements in the sequence. The second line contains $n$ space-separated integers representing the sequence.

outputFormat

Output a single integer on standard output (stdout): the beauty of the sequence, which is the maximum number of distinct integers in any contiguous subarray.

## sample
5
1 2 1 3 2
3