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

#GL0000330. Loại bỏ phần tử bằng phép AND (Array Elimination)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Loại bỏ phần tử bằng phép AND (Array Elimination)

Array Elimination

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array of nn nonnegative integers a1,…,ana_1,\ldots,a_n, an elimination operation with a fixed parameter kk (1≤k≤n1\le k\le n) is defined as follows:

  1. Choose exactly kk distinct positions.
  2. Compute xx, the bitwise AND of the values at those positions.
  3. Subtract xx from each selected array element; all other elements remain unchanged.

Choose kk once before performing any operations, and keep the same kk throughout. Find all values kk for which the whole array can become zero after finitely many operations. Print them in increasing order.

PHOJ input adaptation: Each file contains one array, omitting the original Codeforces leading number of test cases tt.

Input

The first line contains nn. The second line contains nn nonnegative integers aia_i.

Output

Print all valid values of kk on one line, separated by spaces, in ascending order.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le20; 0≤ai<260\le a_i<2^6.
  • Subtask 2 (30 points): 1≤n≤50001\le n\le5000; 0≤ai<2160\le a_i<2^{16}.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le200000; 0≤ai<2300\le a_i<2^{30}.

Examples

Example 1

Input

4
4 4 4 4

Output

1 2 4

Explanation

The bit worth 44 occurs in all four elements. The four occurrences must be partitionable into groups of size kk, so the allowed positive divisors are 1,2,41,2,4.

Example 2

Input

4
13 7 25 19

Output

1 2

Explanation

Across bit positions 0,1,2,3,40,1,2,3,4, the counts of set bits are 4,2,2,2,24,2,2,2,2. Their GCD is 22, so k=1k=1 or k=2k=2.

Example 3

Input

5
0 0 0 0 0

Output

1 2 3 4 5

Explanation

The array is already zero, so no operations are required; every kk from 11 to 55 is valid.