SQRPERF - So Many Squares

no tags 

Juliany is a young programmer in love with math. And as such, it has your favorite numbers. She loves perfect squares, is completely fascinated by them and their gorgeous properties. So she invents several games and hobbies related to them.

One of the games Juliany invented was the insane "So Many Squares" which she plays every day in the intervals of job with her colleague Felipe. The game consists of Felipe choosing N natural numbers, and from these numbers, Juliany has to say how many different ways she can choose some, or possibly all, of these numbers in such a way that their multiplication is a perfect square. Obviously the job of thinking about so many numbers and still wondering if your colleague's answer is correct is not as exciting for Felipe as for Juliany. For this reason and to facilitate his work, he simply chooses a small group of prime numbers, at most 50, and generates the N numbers for the game from those primes. The generated numbers have only prime factors belonging to this group.

Your task is to help Felipe. Since he has already generated the numbers, you should make a program that checks whether Juliany's answer is correct. Since this can be a very large number, your answer should be only the module of that number by 109 + 7.

Input

he input is composed of several test cases. The first line of a test case contains an integer N (1 ≤ N ≤ 104) as described above. The next line contains N integers Ai (1 ≤ Ai ≤ 106) representing the numbers generated by Felipe. The input ends when N = 0.

Output

The output consists of one line per test case containing a single integer representing the Juliany's answer module 109 + 7.

Example

Input:

3
2 4 8

4
14 15 35 7

5
6 42 105 63 20

0

Output:

3

0

1


hide comments
:D: 2018-10-14 22:23:09

I agree. Very fun to figure out and implement.

Last edit: 2018-10-14 22:23:28
julkas: 2018-06-07 09:08:10

Good problem.


Added by:Francisco Elio Parente Arcos Filho [UEA]
Date:2018-05-23
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All