#K5636. Maximum Contiguous Blocks of Buildings

    ID: 30181 Type: Default 1000ms 256MiB

Maximum Contiguous Blocks of Buildings

Maximum Contiguous Blocks of Buildings

You are given a sequence of building heights. Your task is to determine the length of the longest contiguous segment of buildings that have the same height. Formally, if you are given a sequence (a_1, a_2, \dots, a_n) then you need to find the maximum length (L) such that there exists an index (i) for which (a_i = a_{i+1} = \dots = a_{i+L-1}). This problem simulates a real-world scenario where the architect wants to know the longest stretch of buildings with an identical height for planning purposes.

inputFormat

The input is read from standard input (stdin) and contains two lines. The first line contains a single integer (n) ((0 \le n \le 10^5)) representing the number of buildings. The second line contains (n) space-separated integers representing the heights of the buildings.

outputFormat

Print a single integer to standard output (stdout) denoting the maximum number of contiguous buildings that have the same height.## sample

6
3 3 2 2 2 1
3