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

#DSU0000086. Danh sách bài hát (Playlist)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Danh sách bài hát (Playlist)

Playlist

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn songs on a cyclic playlist, numbered from 11 to nn, with genres aia_i. Listening begins at song 11, continues through the remaining songs in order, and wraps to the first song after the last.

After two consecutively listened songs have genres xx and yy, if gcd⁡(x,y)=1\gcd(x,y)=1, the second of those songs is removed. Listening resumes at the next remaining song, and the listening history is reset: two more songs must be heard before another deletion. When only one song remains, listening to it twice consecutively still counts.

The process ends when no more songs can be deleted. Output the number of deleted songs followed by their original indices in deletion order.

Input

The first line contains nn. The second line contains a1,a2,…,ana_1,a_2,\ldots,a_n.

Output

Print kk, the number of deletions, followed by the original indices of the deleted songs in order.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le 20, 1≤ai≤1001\le a_i\le 100.
  • Subtask 2 (30 points): 1≤n≤30001\le n\le 3000, 1≤ai≤1061\le a_i\le 10^6.
  • Subtask 3 (50 points): 1≤n≤1051\le n\le 10^5, 1≤ai≤1091\le a_i\le 10^9.

Example

Input

5
5 9 2 10 15

Output

2 2 3

Explanation

Song 22 is removed because gcd⁡(5,9)=1\gcd(5,9)=1. Later song 33 is also removed. No further deletions are possible.