#C1807. Sum of Lowest and Highest Primes
Sum of Lowest and Highest Primes
Sum of Lowest and Highest Primes
Given an array of N integers, your task is to compute the sum of the smallest and the largest prime numbers in the array.
If there are no prime numbers in the array, output -1
.
A prime number is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself.
inputFormat
The input begins with an integer T
representing the number of test cases. For each test case, the first line contains an integer N
(the number of elements in the array). The next line contains N
space-separated integers.
outputFormat
For each test case, output a single line containing the sum of the smallest and largest prime numbers in the array. If no prime numbers exist in the array, output -1
.## sample
3
5
2 3 4 5 8
4
10 15 20 25
6
1 9 11 13 17 19
7
-1
30
</p>