LearnPy Hub
← Arena
EasyRating 1000

Closest Equal Pair

Print the smallest distance |i − j| between two positions holding equal values, or -1 if all values are different.

Input

n, then n integers.

Output

One integer.

Sample 1

Input
6
7 1 3 4 1 7
Output
3

Sample 2

Input
3
1 2 3
Output
-1
solution.py
Output appears here
Closest Equal Pair · Python Arena problem · LearnPy Hub