#Q44. 「一本通 2.1 练习 8」收集雪花

「一本通 2.1 练习 8」收集雪花

Description

Different snowflakes often have different shapes. A student in the north wants to collect snowflakes as gifts for friends in the south. There are n n moments in total, and the shape of the snowflake falling at each moment is given, represented by distinct integers. During the collection process, the students do not want duplicate snowflakes. You can start collecting at any moment a a and stop at moment b b . All snowflakes falling between moments a a and b b will be collected. They wish to collect as many snowflakes as possible.

Input Format

The first line contains a positive integer n n ;

The second line contains n n non-negative integers representing the shapes of the snowflakes at each of the n n moments.

Output Format

The maximum number of snowflakes that can be collected.

Sample 1

5
1 2 3 2 1

3

Data Range and Hint

For 97 points of the data, 1n106,0xi1081\le n \le 10^6, 0\le x_i \le 10^8 . (This is the original data.)

As per user request, an additional 3 points of data are included: 1n106,0xi1091\le n\le 10^6,0\le x_i\le 10^9.