B - Nineball 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200 点

問題文

あなたはビリヤードのナインボールで遊んでいます。

このゲームでは、 1 から 9 までの番号がついたボールを 1 つずつ、計 9 個のボールを使用します。
現在、卓上には K 個のボールが残っており、各ボールの番号は A_1,A_2,\dots,A_K です。
次はあなたの手番であり、あなたは卓上に残っている最小の番号のボールを狙わなければなりません。ただし、卓上から 9 番のボールが無くなっている場合は、既にゲームが終了しています。

あなたが手番で狙うべきボールの番号を出力してください。 ただし、卓上に 9 番のボールがない場合、ゲームが既に終わっているため、代わりに -1 を出力してください。

制約

  • 入力は全て整数
  • 1 \le K \le 9
  • 1 \le A_i \le 9
  • A_i は相異なる

入力

入力は以下の形式で標準入力から与えられる。

K
A_1 A_2 \dots A_K

出力

答えを出力せよ。


入力例 1

5
6 4 2 9 8

出力例 1

2

卓上に 2,4,6,8,9 番のボールが残っており、次に狙うべきは 2 番のボールです。


入力例 2

4
8 2 4 6

出力例 2

-1

卓上に 2,4,6,8 番のボールが残っていますが、 9 番のボールが残っていません。
この場合はゲームが既に終わっているため、答えは -1 です。


入力例 3

3
7 9 6

出力例 3

6

Score : 200 points

Problem Statement

You are playing nine-ball, a billiards game.

This game uses a total of 9 balls, one for each number from 1 to 9.
Currently, K balls remain on the table, and their numbers are A_1,A_2,\dots,A_K.
It is now your turn, and you must aim at the lowest-numbered ball remaining on the table. However, if the ball numbered 9 is no longer on the table, the game has already ended.

Print the number of the ball you should aim at on your turn. However, if the ball numbered 9 is not on the table, the game has already ended, so print -1 instead.

Constraints

  • All input values are integers.
  • 1 \le K \le 9
  • 1 \le A_i \le 9
  • The values A_i are distinct.

Input

The input is given from Standard Input in the following format:

K
A_1 A_2 \dots A_K

Output

Print the answer.


Sample Input 1

5
6 4 2 9 8

Sample Output 1

2

The balls numbered 2,4,6,8,9 remain on the table, and the ball you should aim at next is the one numbered 2.


Sample Input 2

4
8 2 4 6

Sample Output 2

-1

The balls numbered 2,4,6,8 remain on the table, but the ball numbered 9 does not.
In this case, the game has already ended, so the answer is -1.


Sample Input 3

3
7 9 6

Sample Output 3

6