Permodations

0

0 votes
Hard
Problem

Nobita likes Remainders a lot.One Day Shizuka  gave a task on Remainders which is as Follows : 

Given an Array of size N.Find the Value of the Expression :

                            (....(amod a2)mod a3).......mod an-1) mod an  

Note : x mod y gives remainder when x is divided by y.

Unluckily he lost the order of the Array but has the elements present in the array.So He thought to Calculate above expression for each permutaion of above given array and tell Shizuka the number of UNIQUE Values from above calculated values.

Can you help him in the task so that he can impress Shizuka ?

 

INPUT 

The first line of input contains an integer N (2 ≤ N ≤ 100) which is the amount of numbers in Petya’s expression. The second line contains N space-separated positive integers not exceeding 3*105

 

OUTPUT

Single Integer specifying Number of Unique values after calculating for each permutation.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the example, only three permutations of ai are possible. All of them lead to different results:

                                    (7 mod 10) mod 10 = 7,

                                    (10 mod 7) mod 10 = 3,

                                    (10 mod 10) mod 7 = 0.

Editor Image

?