MUSVIOMG - Robert Plays The Viola


Robert is a proud viola player — one of the rare few who chose the path of rich scratchy tones over the flashy squeaks of the violin or the booming drama of the cello. But there’s one thing Robert cannot stand: repeated notes.

You see, as a violist, Robert believes every note should serve a unique purpose in a melody. Whenever a passage contains the same note more than once in a short span, he finds it… distasteful. He insists that such sequences are lazy and uninspired, no better than violin solos.

Today, while reviewing a composition (which suspiciously resembles a sequence of numbers), Robert noticed a disturbing pattern. He wants to check whether there is any contiguous passage of notes that includes the same note more than once. If there is, he'd like to know the length of the shortest such passage, so he can circle it in red ink and write “Try harder.”

Can you help Robert identify whether such a dreadful repetition exists?

You will be given an array A representing the composition of length N, determine whether there exists a non-empty contiguous subarray of A that contains a repeated value — i.e., a value that appears at least twice within the subarray. If such a subarray exists, find the length of the shortest such subarray.

Input

You are given a positive integer N(1<=N<=10^5) in the first line

In the second line there will be an integer sequence A = (A₁, A₂, ..., Aₙ) of length N.

Output

If there is no subarray that satisfies the condition, output -420. Otherwise print the length of such subarray.

Example

Input:
6
4 7 2 1 4 9
Output:
5


Added by:OuiOuiBaguette
Date:2025-04-24
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All