#C7384. Product of Primes

    ID: 51249 Type: Default 1000ms 256MiB

Product of Primes

Product of Primes

Given a list of integers, your task is to compute the product of all prime numbers contained in the list. A prime number is an integer \(n\) greater than 1 that has no positive divisors other than 1 and \(n\) itself. If there is no prime number in the list, you should return 1.

Input Format: The first line contains an integer \(n\) representing the number of elements in the list. The second line contains \(n\) space separated integers.

Output Format: Print a single integer, which is the product of all the prime numbers in the input list. If there is no prime in the list, output 1.

Example: For the input "5\n2 3 4 7 8", the prime numbers are 2, 3, and 7, and their product is \(2 \times 3 \times 7 = 42\).

inputFormat

Standard input: The first line contains an integer n, denoting the number of integers in the list. The second line contains n space-separated integers.

outputFormat

Standard output: Print a single integer which is the product of the prime numbers in the list. If there are no prime numbers, print 1.## sample

5
2 3 4 7 8
42