#GL0000150. Buổi hòa nhạc năm mới (New Year Concert)
Bài tập thuộc lộ trình
Mục lục đề ⌄
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 is preparing a concert. Class has a scene of duration . A sequence is considered boring if there exists an interval for which
The organizer may choose some positions and replace their values with arbitrary positive integers. For every prefix , let be the minimum number of changed positions needed so that no boring interval remains.
Compute . Every prefix is assessed independently using the original array.
Input
The first line contains . The next line contains positive integers .
Output
Print space-separated integers .
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
7
2 12 4 8 18 3 6
Output
0 1 1 1 2 2 2
Explanation
Prefix is not boring because , hence . For , the full interval has GCD and length , 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 for the remaining prefixes.