QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 64 MB Total points: 100

#567. Beads

统计

Byteasar once decided to start manufacturing necklaces. He subsequently bought a very long string of colourful coral beads for a bargain price. Byteasar now also has a machine that, for a given $k$ ($k > 0$), can cut the string into pieces (or substrings) of $k$ coral beads (i.e., the first piece consists of the beads no. $1,…,k$, the second of $k+1,…,2k$, etc.). If the length of the string (measured in coral beads) is not a multiple of , then the last piece is not used, as it has length smaller than $k$. From now on we denote the colours of the beads with positive integers.

Byteasar, always praising diversity, wonders how he should choose the number $k$ in order to get as many different substrings as possible. The ends of the long string that will be cut are different: there are specific beginning and ending (rather than two interchangeable endpoints), and the machine of course starts cutting at the beginning. On the other hand, in the substrings obtained from cutting the endpoints are interchangeable, and so the substrings can be reversed. In other words, the substrings (1,2,3) and (3,2,1) are identical to us. Write a program that determines the optimum value of $k$ for Byteasar.

For example, for the following string of beads:

$$(1,1,1,2,2,2,3,3,3,1,2,3,3,1,2,2,1,3,3,2,1)$$

  • using $k=1$, we would get 3 different substrings: (1), (2), (3),
  • using $k=2$, we would get 6 different substrings: (1,1), (1,2), (2,2), (3,3), (3,1), (2,3),
  • using $k=3$, we would get 5 different substrings: (1,1,1), (2,2,2), (3,3,3), (1,2,3), (3,1,2),
  • using $k=4$, we would get 5 different substrings: (1,1,1,2), (2,2,3,3), (3,1,2,3), (3,1,2,2), (1,3,3,2),
  • using larger values of $k$ would give at most 3 different substrings.

Input

In the first line of the standard input there is an integer $n$ ($1 ≤ n ≤ 200\,000$) denoting the length of the string to cut. In the second line there are $n$ positive integers $a_i$ ($1 ≤ a_i ≤ n$), separated by single spaces, that denote the colours of successive beads in Byteasar's string.

Output

Two integers, separated by a single space, should be printed out to the first line of the standard ouput: the (maximum) number of different substrings that can be obtained with an optimal choice of parameter $k$, and the number $l$ of such optimal values of $k$. The second line should contain $l$ integers separated by single spaces: the values of parameter $k$ that yield an optimum solution; these can be given in arbitrary order.

Example

Input

21
1 1 1 2 2 2 3 3 3 1 2 3 3 1 2 2 1 3 3 2 1

Output

6 1
2

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.