Lucky ticket 2#2619

Lucky ticket 2

1 second
64 megabytes
Very easy

A ticket is a sequence of digits of length . A ticket is called happy if there exists a number (1 \le k \le n) such that [...]. The number in this case is called the happiness boundary.

Your task is to write a program that, given a ticket, determines its smallest happiness boundary, if it exists.

Input

The first line of the input file contains the number (2 \le n \le 10^6) — the length of ticket . The second line contains the digits a_1,\, a_2,\, \ldots,\, a_n (0 \le a_i \le 9), separated by spaces.

Output

If the ticket is happy, output its smallest happiness boundary; otherwise, output **-1**.

Examples

Example 1

Loading
Loading