ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

1053. Pinocchio

Time limit: 1.0 second
Memory limit: 64 MB
Father Carlo got the commission to make Pinocchio. Client expressed a wish to be unknown and he left material and insisted on finding Pinocchio's nose length as a result of performing the following algorithm:
  1. There's a set of N numbered blanks with integer lengths.
  2. If the set consists of only one blank, then it's length can be admitted as the length of Pinocchio's nose
  3. Let's choose some 2 blanks
    1. If lengths of the blanks coincide, then one of the blanks is eliminated from the set and algorithm goes back to point 2 to be repeated.
    2. If lengths of the blanks are different, then the piece of the long blank is sawed off and its length must be equal to the length of the other blank. Then the algorithm is repeated from point 2.
Example. There are 3 blanks in a set with lengths: 2, 3, 4. Then the change of the blank lengths can be shown in the following table. As a result Pinocchio will get the nose with length of 1.
Length of the
first blank
Length of the
second blank
Length of the
third blank
2 3 4 Initial blank lengths
2 1 4 Sawing off the second blank
2 1 3 Sawing off the third blank
2 1 2 Sawing off the third blank
1 1 2 Sawing off the first blank
- 1 2 The first blank is eliminated
- 1 1 Sawing off the third blank
- - 1 The second blank is eliminated


The first line contains integer N (1 ≤ N ≤ 1000). The other N successive lines contain integers L1, L2, …, LN.
1 ≤ L1, L2, …, LN ≤ 231 − 1.


Output should contain either one number (Pinocchio nose length), or the word IMPOSSIBLE (in upper case) if the nose length cannot be defined.


Problem Source: Rybinsk State Avia Academy