MSKYCODE - Sky Code

no tags 

Stancu likes space travels but he is a poor software developer and will never be able to buy his own spacecraft. That is why he is preparing to steal the spacecraft of Petru. There is only one problem – Petru has locked the spacecraft with a sophisticated cryptosystem based on the ID numbers of the stars from the Milky Way Galaxy. For breaking the system Stancu has to check each subset of four stars such that the only common divisor of their numbers is 1. Nasty, isn’t it?

Fortunately, Stancu has succeeded to limit the number of the interesting stars to N but, any way, the possible subsets of four stars can be too many. Help him to find their number and to decide if there is a chance to break the system.

Input

In the input file several test cases are given. For each test case on the first line the number N of interesting stars is given (1 ≤ N ≤ 10000).

The second line of the test case contains the list of ID numbers of the interesting stars, separated by spaces. Each ID is a positive integer which is no greater than 10000. The input data terminate with the end of file.

Output

For each test case the program should print one line with the number of subsets with the asked property.

Sample

Input :
4  
2 3 4 5 
4 
2 4 6 8 
7 
2 3 4 5 7 6 8 
Ouput: 
1 
0 
34 

hide comments
Govardhan Reddy M: 2013-06-05 12:55:45

Can there be duplicate stars ?

爆炸王旭: 2012-12-06 07:05:06

How Can It Gave Me A NZEC?
I Use PASCAL But Got A NZEC!

edit by skyvn97: NZEC=Non Zero Exit Code

Last edit: 2014-03-12 15:44:22
(Tjandra Satria Gunawan)(曾毅昆): 2012-08-05 17:23:08

TLE :(

~!(*(@*!@^&: 2009-04-17 18:28:14

Rejude with 3s time limits. 1 TLE (13s).

Last edit: 2009-04-17 22:40:36

Added by:~!(*(@*!@^&
Date:2009-04-09
Time limit:0.136s-0.451s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:Southeastern European 2008