#C11641. Distinct Prime Factors of Array Sum

    ID: 40980 Type: Default 1000ms 256MiB

Distinct Prime Factors of Array Sum

Distinct Prime Factors of Array Sum

Given an array of N integers, calculate the sum of all the elements. If the sum is a prime number, output 1. Otherwise, output the number of distinct prime factors of the sum. The factors should be considered only once regardless of their multiplicity.

For example:

  • For an array [2, 4, 7] with N=3, the sum is 13 which is prime, so the output is 1.
  • For an array [10] with N=1, the sum is 10 and its distinct prime factors are 2 and 5, so the output is 2.

Your task is to implement a solution that reads the input from standard input and writes the output to standard output.

inputFormat

The first line of input consists of a single integer N, the number of array elements.

The second line contains N space-separated integers representing the elements of the array.

outputFormat

Output a single integer which is either 1 if the sum of the array is prime, or the number of distinct prime factors of the sum if it is composite.

## sample
3
2 4 7
1

</p>