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

#GL0000386. Đếm tập con theo ước chung lớn nhất (GCD Subsets)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Đếm tập con theo ước chung lớn nhất (GCD Subsets)

GCD Subsets

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

You are given an array x1,…,xnx_1,\ldots,x_n of positive integers. A non-empty subset selects one or more positions, so equal values at different positions are still distinct choices.

For every k=1,2,…,nk=1,2,\ldots,n, count the non-empty subsets whose elements have GCD exactly kk. Print the counts modulo 109+710^9+7.

Input

  • First line: the integer nn.
  • Second line: nn integers x1,…,xnx_1,\ldots,x_n.

Output

Print nn integers. The kk-th integer counts subsets of GCD kk modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤n≤121\le n\le12 and 1≤xi≤n1\le x_i\le n.

  • Subtask 2 (30 points): 1≤n≤2 0001\le n\le2\,000 and 1≤xi≤n1\le x_i\le n.

  • Subtask 3 (50 points): 1≤n≤200 0001\le n\le200\,000 and 1≤xi≤n1\le x_i\le n.

Examples

Input

5
5 4 4 2 3

Output

22 4 1 3 1

Explanation

There are 3131 non-empty subsets. Exactly three subsets have GCD 44: choose a non-empty subset of the two positions with value 44. Exactly one subset has GCD 55. Exactly four have GCD 22: select the position holding 22 and any subset of the two positions holding 44. The remaining counts are 2222 for GCD 11 and 11 for GCD 33.