SP4195 MSE08H - GCD Determinant

Description

[English](/problems/MSE08H/en/) [Vietnamese](/problems/MSE08H/vn/) We say that a set S = {x1, x2, …, xn} is factor closed if for any xi ∈ S and any divisor d of xi we have d ∈ S. Let’s build a GCD matrix (S) = (sij), where sij = GCD(xi, xj) – the greatest common divisor of xi and xj. Given the factor closed set S, find the value of the determinant: [![Image and video hosting by TinyPic](https://cdn.luogu.com.cn/upload/vjudge_pic/SP4195/027d0cb08fc2a3fbc74500361335a997209d1b89.png)](http://tinypic.com)

Input Format

The input file contains several test cases. Each test case starts with an integer n (0 < n < 1000), that stands for the cardinality of S. The next line contains the numbers of S: x1, x2, …, xn. It is known that each xi is an integer, 0 < xi < 2\*10^9. The input data set is correct and ends with an end of file.

Output Format

For each test case find and print the value Dn mod 1000000007.