#B2097. Longest Platform in an Array

    ID: 11179 Type: Default 1000ms 256MiB

Longest Platform in an Array

Longest Platform in an Array

Given an array, a consecutive sequence of identical numbers is called a platform. For example, in the array \(1,\ 2,\ 2,\ 3,\ 3,\ 3,\ 4,\ 5,\ 5,\ 6\), the platforms are: \(1\), \(2,2\), \(3,3,3\), \(4\), \(5,5\), \(6\).

Write a program to find and print the longest platform. In the case of multiple platforms of the same maximum length, output the first one encountered.

inputFormat

The first line contains an integer \(n\), the number of elements in the array.
The second line contains \(n\) space-separated integers.

outputFormat

Output the elements of the longest platform separated by a single space.

sample

10
1 2 2 3 3 3 4 5 5 6
3 3 3