#K85262. Unique Prime Cycles

    ID: 36603 Type: Default 1000ms 256MiB

Unique Prime Cycles

Unique Prime Cycles

You are given an integer \(N\) and a sequence of \(N\) prime numbers. A cyclic permutation (or prime cycle) of the list is obtained by rotating the sequence. For example, for the list \([p_1, p_2, p_3]\) the cyclic permutations are:

  • \([p_1, p_2, p_3]\)
  • \([p_2, p_3, p_1]\)
  • \([p_3, p_1, p_2]\)

Two cycles are considered the same if their elements appear in the same order. Your task is to compute the total number of unique prime cycles that can be obtained from the given list.

Input: The first line contains a single integer \(N\) (the number of primes). The second line contains \(N\) space‐separated prime numbers.

Output: Output a single integer, the number of unique prime cycles.

inputFormat

The input is given via stdin and consists of two lines:

  • The first line contains an integer \(N\), representing the number of prime numbers.
  • The second line contains \(N\) space-separated prime numbers.

outputFormat

The output is a single integer printed to stdout which denotes the number of unique cyclic permutations (prime cycles) from the input list.

## sample
3
11 13 17
3

</p>