#K91087. Longest Consecutive Reading Sequence

    ID: 37897 Type: Default 1000ms 256MiB

Longest Consecutive Reading Sequence

Longest Consecutive Reading Sequence

You are given a sequence of integers representing the number of pages read each day. Your task is to find the longest sequence of consecutive days on which the same number of pages were read. The answer should consist of the page count and the length of that sequence.

For example, if the input is 1 2 2 3 3 3 2, the longest consecutive sequence is three days with 3 pages each, so the correct output is 3 3.

In mathematical notation, let \(a_i\) denote the number of pages read on the \(i\)th day. We need to determine the integer \(x\) and the maximum length \(L\) such that there exists a contiguous subsequence \(a_i = a_{i+1} = \cdots = a_j = x\) where \(L = j - i + 1\) is maximized.

inputFormat

The first line of input contains a single integer \(n\) (\(0 \le n \le 10^5\)), representing the number of days. The second line contains \(n\) space-separated integers, each representing the number of pages read on each day. If \(n = 0\), the second line will be empty.

outputFormat

Output two space-separated integers: the page number corresponding to the longest consecutive sequence, followed by the length of that sequence.

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

</p>