Given a prime number $$$P$$$ and a multiset $$$S$$$ containing $$$P - 1$$$ positive integers, please find out whether there is a non-empty multi-subset $$$S'$$$ of $$$S$$$, such that the product of elements in $$$S'$$$ is $$$1$$$ modulo $$$P$$$. That is,
$$$$$$ \prod_{i \in S'} i \equiv 1 \pmod{P} $$$$$$
.
The first line of the input contains an integer $$$P$$$.
The second line of the input contains $$$P - 1$$$ space-separated integers, which are the elements in $$$S$$$.
Output Yes if there exists a multi-subset $$$S'$$$ satisfing the requirement. Output No otherwise.
5 2 2 3 4
Yes
11 2 2 3 3 4 4 5 5 6 6
Yes
3 1 1
Yes
Name |
---|