#K10041. Longest Consecutive Subsequence

    ID: 23158 Type: Default 1000ms 256MiB

Longest Consecutive Subsequence

Longest Consecutive Subsequence

Given a sequence of integers, your task is to determine the length of the longest consecutive subsequence where all elements are identical.

More formally, let \(a_1, a_2, \dots, a_N\) be a sequence of integers. You need to find the maximum integer \(L\) such that for some index \(i\) (with \(1 \le i \le N - L + 1\)), \[ a_i = a_{i+1} = \dots = a_{i+L-1}. \]

If the sequence is empty (i.e. \(N=0\)), output \(0\).

inputFormat

The input is given via standard input (stdin) and has the following format:

  • The first line contains an integer \(N\) (\(N \ge 0\)), representing the number of elements in the sequence.
  • If \(N > 0\), the second line contains \(N\) integers separated by spaces, representing the sequence. If \(N = 0\), the second line will be absent.

outputFormat

Output via standard output (stdout) a single integer representing the length of the longest consecutive subsequence of identical numbers.

## sample
7
1 2 2 2 3 3 4
3