Alan works at a company that specialises in computer security. He designed a public key cryptosystem in which the private key is a pair of permutations π and σ of {1,…,n}. The public key (a1,…,an) is then given by ai≡πi+σi(modn) for 1≤i≤n. The notation x≡y(modn) means that x and y leave the same remainder when divided by n.
Take n=5 with
The public key is then a=(3,2,3,1,1). For instance a5≡1≡4+2≡π5+σ5(mod5), and each of π and σ contains every number of {1,…,5} exactly once.
Alan's coworkers doubt that the system is secure, since any private key matching the public key breaks it. Help them out. Given n and a sequence a=(a1,…,an), decide whether there are permutations π and σ of {1,…,n} with πi+σi≡ai(modn) for every i.
The first line contains the length n of the sequence (1≤n≤1000).
The second line contains n integers a1,…,an (1≤ai≤n).
Print possible if permutations π and σ with the property above exist, and impossible otherwise.