#C3679. Check if All Numbers are 1 or Prime
Check if All Numbers are 1 or Prime
Check if All Numbers are 1 or Prime
Given a list of integers, determine whether every integer is either 1 or a prime number.
A number \(p\) is defined as prime if \(p > 1\) and its only divisors are \(1\) and \(p\). Equivalently, in mathematical terms, for every integer \(d\) satisfying \(2 \le d \le \sqrt{p}\), it holds that \(d\) does not divide \(p\).
Your program should read from the standard input (stdin) and output the result to the standard output (stdout) as either True
or False
. The result is True
if each number in the list is either 1 or prime; otherwise, the result is False
.
inputFormat
The first line of input contains a single integer \(n\) (\(1 \le n \le 10^5\)), the number of elements in the list.
The second line contains \(n\) space-separated integers. Each integer \(a_i\) satisfies \(|a_i| \le 10^9\).
outputFormat
Output a single line with either True
if every element in the list is either 1 or a prime number, or False
otherwise.
5
1 2 3 5 7
True