408808: GYM103328 E Identity Subset

Memory Limit:1024 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Identity Subsettime limit per test3 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

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} $$$$$$

.

Input

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$$$.

  • $$$2 \leq P \leq 100000$$$
  • It's guaranteed that $$$P$$$ is a prime number
  • For each $$$x \in S$$$, $$$1 \leq x \leq 10^9$$$
Output

Output Yes if there exists a multi-subset $$$S'$$$ satisfing the requirement. Output No otherwise.

ExamplesInput
5
2 2 3 4
Output
Yes
Input
11
2 2 3 3 4 4 5 5 6 6
Output
Yes
Input
3
1 1
Output
Yes

加入题单

算法标签: