#K58177. Longest Contiguous Subarray

    ID: 30585 Type: Default 1000ms 256MiB

Longest Contiguous Subarray

Longest Contiguous Subarray

You are given an array of integers. Your task is to determine the length of the longest contiguous subarray in which every element is the same.

For example, given the array [2, 2, 2, 3, 3], the longest contiguous subarray with the same element is [2, 2, 2] and its length is 3. If the array is empty, the answer is 0.

Note: The solution should work in O(n) time complexity.

inputFormat

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

N
A1 A2 A3 ... AN

Where N (an integer) represents the number of elements in the array and A1, A2, ..., AN are the integers separated by spaces. If N is 0, there will be no subsequent elements.

outputFormat

Output a single integer to standard output (stdout) — the length of the longest contiguous subarray where all the elements are the same.

## sample
5
2 2 2 3 3
3