D - Max Straight 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 400

問題文

長さ N の整数列 A=(A_1,A_2,\ldots,A_N) が与えられます。

整数列 A の部分列 B=(B_1,B_2,\ldots,B_{|B|}) であって、以下の条件を満たすものの長さの最大値を求めてください。

  • 全ての 1\le i\le |B| - 1 を満たす整数 i に対し、 B_i+1=B_{i+1} が成り立つ。
部分列とは 数列 A の部分列とは、A の要素を 0 個以上選んで削除し、残った要素を元の順序を保って並べた数列のことを指します。

制約

  • 1\le N\le 2\times 10^5
  • 1\le A_i\le 10^9
  • 入力される値は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N
A_1 A_2 \ldots A_N

出力

答えを出力せよ。


入力例 1

7
3 4 3 5 7 6 2

出力例 1

4

B=(3,4,5,6)A の部分列であり条件を満たし、その長さは 4 です。

条件を満たす部分列であって長さが 4 より長いものは存在しないので、 4 を出力してください。


入力例 2

5
5 4 3 2 1

出力例 2

1

入力例 3

10
1 2 3 4 5 6 7 8 9 10

出力例 3

10

Score : 400 points

Problem Statement

You are given an integer sequence A=(A_1,A_2,\ldots,A_N) of length N.

Find the maximum length of a subsequence B=(B_1,B_2,\ldots,B_{|B|}) of integer sequence A that satisfies the following condition.

  • B_i+1=B_{i+1} for all integers i satisfying 1\le i\le |B| - 1.
What is a subsequence A subsequence of sequence A is a sequence obtained by choosing zero or more elements of A to delete, and arranging the remaining elements in their original order.

Constraints

  • 1\le N\le 2\times 10^5
  • 1\le A_i\le 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 \ldots A_N

Output

Output the answer.


Sample Input 1

7
3 4 3 5 7 6 2

Sample Output 1

4

B=(3,4,5,6) is a subsequence of A that satisfies the condition, and its length is 4.

There is no subsequence satisfying the condition with length greater than 4, so output 4.


Sample Input 2

5
5 4 3 2 1

Sample Output 2

1

Sample Input 3

10
1 2 3 4 5 6 7 8 9 10

Sample Output 3

10