Fighting Monsters
Emma just discovered a new card game called Gwint: A wizard’s game. There are two types of cards: monster cards and spell cards. Monster cards are used to score points, while spell cards typically interact with the monsters in some way.
On each monster card there is an integer value, the power of the monster. Monsters can fight each other, and during these fights the power acts as both the strength and the health of the monster. The monsters take turns hitting each other until one of them dies. Whenever a monster hits a monster , this causes to lose an amount of power equal to the power of . Conversely, if hits , loses power equal to the power of (see the example below). This continues until one of the two monsters has a power of zero or less, at which point this monster is considered dead.
A fight between monsters and , starting with powers of and , respectively. hits first. wins with a remaining power of .
One of Emma’s most beloved cards in the game is a spell called Fight! which states:
Pick two monsters. They fight each other to the death. If the surviving monster has a power of exactly left, return this card to your hand.
Of course, Emma would like to play as efficiently as possible by picking two monsters such that Fight! is returned to her hand. However, there are often a lot of monsters on the board, which makes it very time consuming to figure out whether this can be done or not. Can you help her find two monsters she can pick so that she gets the card back?
Input
The first line contains an integer , the number of monsters.
The next line has integers , giving the power of each monster.
Output
If there is no pair of monsters that Emma can pick, output impossible.
Otherwise, output two distinct integers , where is the index of the monster that starts the fight and is the index of the other monster. If multiple solutions exist, any of them will be accepted.