PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000151. Cặp chỉ số của đoạn tối ưu (Pair of Numbers)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Cặp chỉ số của đoạn tối ưu (Pair of Numbers)

Pair of Numbers

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Simon has a sequence of positive integers A1,…,ANA_1,\ldots,A_N. An interval [L,R][L,R] is valid if there exists an index JJ inside the interval such that every AiA_i in that interval is divisible by AJA_J.

Among all valid intervals, maximize R−LR-L (one less than the interval length). If several intervals attain the maximum, output all their starting indices LL in increasing order.

Input

The first line contains NN. The second line contains the NN values AiA_i.

Output

The first line contains the number of optimal intervals and the maximum R−LR-L. The second line contains all optimal starting indices LL in increasing order.

Subtasks

  • Subtask 1 (20 points): 1≤N≤501 \le N \le 50; 1≤Ai≤1001 \le A_i \le 100.
  • Subtask 2 (30 points): 1≤N≤50001 \le N \le 5000; 1≤Ai≤1051 \le A_i \le 10^5.
  • Subtask 3 (50 points): 1≤N≤3⋅1051 \le N \le 3\cdot10^5; 1≤Ai≤1061 \le A_i \le 10^6.

Examples

Input

5
4 6 9 3 6

Output

1 3
2

Explanation

The interval [2,5]=[6,9,3,6][2,5]=[6,9,3,6] is valid because its element 33 divides every entry. It has length 44, so R−L=3R-L=3. The entire length-55 array is invalid: its GCD is 11, which does not occur as an array element. Exactly one interval attains length 44.