The Addition Game

No attempts yetTime limit1sMemory limit256 MB

Problem

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 π\pi and σ\sigma of {1,,n}\{1, \dots, n\}. The public key (a1,,an)(a_1, \dots, a_n) is then given by aiπi+σi(modn)a_i \equiv \pi_i + \sigma_i \pmod n for 1in1 \le i \le n. The notation xy(modn)x \equiv y \pmod n means that xx and yy leave the same remainder when divided by nn.

Take n=5n = 5 with

  • π=(3,1,5,2,4)\pi = (3, 1, 5, 2, 4),
  • σ=(5,1,3,4,2)\sigma = (5, 1, 3, 4, 2).

The public key is then a=(3,2,3,1,1)a = (3, 2, 3, 1, 1). For instance a514+2π5+σ5(mod5)a_5 \equiv 1 \equiv 4 + 2 \equiv \pi_5 + \sigma_5 \pmod 5, and each of π\pi and σ\sigma contains every number of {1,,5}\{1, \dots, 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 nn and a sequence a=(a1,,an)a = (a_1, \dots, a_n), decide whether there are permutations π\pi and σ\sigma of {1,,n}\{1, \dots, n\} with πi+σiai(modn)\pi_i + \sigma_i \equiv a_i \pmod n for every ii.

Input

The first line contains the length nn of the sequence (1n10001 \le n \le 1000).

The second line contains nn integers a1,,ana_1, \dots, a_n (1ain1 \le a_i \le n).

Output

Print possible if permutations π\pi and σ\sigma with the property above exist, and impossible otherwise.