#C8401. Prime Difference

    ID: 52380 Type: Default 1000ms 256MiB

Prime Difference

Prime Difference

Given an array of integers, determine the difference between the largest and smallest prime numbers contained in the array. A prime number is defined as an integer (n > 1) that has no divisors other than 1 and itself; formally, for every integer (d) with (2 \le d \le \sqrt{n}), (d) does not divide (n). If the array contains fewer than two prime numbers, output (-1).

inputFormat

The input is read from stdin. The first line contains an integer (n), the number of elements in the array. The second line contains (n) space-separated integers representing the elements of the array.

outputFormat

Output to stdout a single integer which is the difference between the largest and smallest prime numbers in the array. If the array contains fewer than two prime numbers, output (-1).## sample

5
10 15 3 7 19
16