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

#GL0000150. Buổi hòa nhạc năm mới (New Year Concert)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Buổi hòa nhạc năm mới (New Year Concert)

New Year Concert

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

School 179179 is preparing a concert. Class ii has a scene of duration AiA_i. A sequence B1,…,BKB_1,\ldots,B_K is considered boring if there exists an interval [L,R][L,R] for which

gcd⁡(BL,BL+1,…,BR)=R−L+1.\gcd(B_L,B_{L+1},\ldots,B_R)=R-L+1.

The organizer may choose some positions and replace their values with arbitrary positive integers. For every prefix [A1,…,Ai][A_1,\ldots,A_i], let f(i)f(i) be the minimum number of changed positions needed so that no boring interval remains.

Compute f(1),…,f(N)f(1),\ldots,f(N). Every prefix is assessed independently using the original array.

Input

The first line contains NN. The next line contains NN positive integers AiA_i.

Output

Print NN space-separated integers f(1),…,f(N)f(1),\ldots,f(N).

Subtasks

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

Examples

Input

7
2 12 4 8 18 3 6

Output

0 1 1 1 2 2 2

Explanation

Prefix [2][2] is not boring because gcd⁡(2)=2≠1\gcd(2)=2\ne1, hence f(1)=0f(1)=0. For [2,12][2,12], the full interval has GCD 22 and length 22, so one change is necessary. One change remains sufficient through the fourth prefix; a second disjoint obstruction appears by the fifth position, bringing the minimum to 22 for the remaining prefixes.