You are given an array of n integer numbers a_0, a_1, ..., a_{n} - 1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times.


-----Input-----

The first line contains positive integer n (2 ≤ n ≤ 10^5) — size of the given array. The second line contains n integers a_0, a_1, ..., a_{n} - 1 (1 ≤ a_{i} ≤ 10^9) — elements of the array. It is guaranteed that in the array a minimum occurs at least two times.


-----Output-----

Print the only number — distance between two nearest minimums in the array.


-----Examples-----
Input
2
3 3

Output
1

Input
3
5 6 5

Output
2

Input
9
2 1 3 5 4 1 2 3 1

Output
3

Difficulty: interview

Starter code:

Solutions:
n = int(input())
A = [int(x) for x in input().split()]
mn = min(A)

I = [i for i in range(len(A)) if A[i] == mn]
mindiff = min(I[i]-I[i-1] for i in range(1,len(I)))
print(mindiff)


n = int(input())
z = list(map(int, input().split()))
for i in range(n):
    z[i] = [z[i], i]
z.sort()
ans = 1e9
for i in range(1, n):
    if z[i][0] == z[0][0]:
        ans = min(ans, z[i][1] - z[i - 1][1])
print(ans)


n = int(input())
L = list(map(int, input().split()))

x = min(L)

prv = -1
ans = 10**100
for i in range(n):
	if (L[i] == x):
		if (prv != -1):
			ans = min(ans, i - prv);
		prv = i
print(ans)

n = int(input())

a = list(map(int, input().strip().split()))

x = min(a)

best = 10**6
last = None
i = 0
while i < len(a):
    if a[i] == x:
        if last is None:
            last = i
        else:
            razlika = i - last
            best = min(razlika, best)
            last = i
    i += 1
print(best)


n=int(input())
A=[int(i) for i in input().split(" ")]
x=min(A)
ans=n
for i in range(n):
    if A[i]==x:
        j=1
        while i+j<n and A[i+j]!=x:
            j+=1
        if i+j<n and A[i+j]==x:
            ans=min(ans, j)
print(ans)


n=int(input())
l=list(map(int,input().split()))
x=min(l)
ls=[]
for i in range(n):
    if l[i]==x:
        ls.append(i)
ans=n+1
for i in range(len(ls)-1):
    ans=min(ans,ls[i+1]-ls[i])
print(ans)

n=int(input())
a=[int(i) for i in input().split()]
p=[]
z=min(a)
for i in range(n):
    if a[i]==z:
        p.append(i)
x=[]
for i in range(len(p)-1):
    x.append(p[i+1]-p[i])
print(min(x))


from sys import stdin, stdout

INF = float('inf')
n = int(stdin.readline())
values = list(map(int, stdin.readline().split()))

ans = INF
previous = -INF
mn = min(values)

for i in range(n):
    if values[i] == mn:
        ans = min(ans, i - previous)
        previous = i

stdout.write(str(ans))

n = int(input())
s = list(map(int, input().split()))
q = set()
p = []
m = min(s)
z = 0
for i in range(len(s)):
	if s[i] == m:
		p.append(i)
z = [p[i + 1] - p[i] for i in range(len(p) - 1)]
print(min(z))


n = int(input())
a = list(map(int, input().split()))

mn = min(a)
pm = None
ans = n+1
for i in range(n):
    if a[i] == mn:
        if pm is not None:
            ans = min(ans, i - pm)
        pm = i
print(ans)

n=int(input())
arr=list(map(int,input().strip().split(' ')))
p=min(arr)
flag=0
ans=100000000
for i in range(n):
	if(arr[i]==p and flag==0):
		start=i
		flag=1
	elif(arr[i]==p and flag==1):
		ans=min(ans,i-start)
		start=i
print(ans)



n=int(input())
ar=list(map(int,input().split()))
mn=min(ar)
prev=-float('inf')
ans=float('inf')
for i in range(n):
    if ar[i] == mn:
        ans=min(ans,i-prev)
        prev=i
print(ans)


n=int(input())
num=list(map(int,input().split()))
mn=min(num)
i=0
while num[i]!=mn:	
	i+=1
cur=i
ans=n
for i in range(cur+1,n):
	if(num[i]==mn):
		ans=min(ans,i-cur)
		cur=i
print (ans)

n=int(input())
a=list(map(int,input().split()))
mini=min(a)
s1=a.index(mini)
s2=0
for i in range(s1+1,n):
    if(a[i]==mini):
        s2=i
        break
ans=s2-s1
for i in range(s2+1,n):
    if(a[i]==mini):
        ans=min(ans,i-s2)
        s1=s2
        s2=i
print(ans)


n = input()
arr = list(map(int, input().strip().split()))

mini = None
min_dist = None
positions = []
last = -1
for i, a in enumerate(arr):
    if mini is None or a < mini:
        mini = a
        last = i
        min_dist = None
    elif mini == a:
        d = i - last
        if min_dist is None or d < min_dist:
            min_dist = d
        last = i
print(min_dist)


a = int(input())
l = [int(i)for i in input().split()]
x = min(l)
id = 0
for i in l:
	if i == x:break
	id += 1
d = 1000000
for j in range(id+1,len(l)):
	if l[j] == x:
		d = min(d,j - id)
		id = j
print(d)		

n = int(input())
a = list(map(int, input().split()))

m = min(a)

ans = 1000000000
prev = -1

for i in range(n):
    if a[i] == m:
        if prev != -1:
            ans = min(ans, i - prev)
        prev = i


print(ans)


k = int(input())
x = list(map(int,input().split()))
m = min(x)
z = []
for i in range(k):
	if x[i] == m:
		z += [i]
j = []
for i in range(1, len(z)):
	j += [z[i] - z[i-1]]
print(min(j))


n = int(input())
a = list(map(int, input().split()))
x = min(a)
length = n
ind = -1
for i in range(n):
	if a[i] == x and ind == -1:
		ind = i
	elif a[i] == x and ind >= 0:
		if i - ind < length:
			length = i - ind
		ind = i
print(length)			


n = int(input())
a = [int(x) for x in input().strip().split(' ')]
m = min(a)

i = [x for x in range(n) if a[x] == m]

d = [i[x + 1] - i[x] for x in range(len(i) - 1)]
print(min(d))


n = int(input())
a = [int(v) for v in input().split()]

bestd = len(a)
mi = 0
m = a[0]
for i in range(1, len(a)):
    if a[i] < m:
        m = a[i]
        mi = i
        bestd = len(a)
    elif a[i] == m:
        currd = i - mi
        if currd < bestd:
            bestd = currd
        mi = i

print(bestd)


import sys
taille = int(sys.stdin.readline())
tableau = list(map(int, sys.stdin.readline().split()))
mini = min(tableau)
pre = -1
minDist = 10**7
for loop in range(taille):
	if tableau[loop] == mini:
		if pre == -1:
			pre = loop
		else:
			minDist = min(loop-pre, minDist)
			pre = loop
print(minDist)		

n = int(input())
a = list(map(int, input().split()))
mn = min(a)
incs = []
for i in range(len(a)):
	if a[i] == mn:
		incs.append(i)
print(min([incs[i] - incs[i - 1] for i in range(1, len(incs))]))

def lInt(d = None): return list(map(int, input().split(d)))

n, *_ = lInt()
a = list(lInt())
mini = min(a)
p = []
ans = 10000000

for i, v in enumerate(a):
  if v == mini:
    p.append(i)
for i, j in enumerate(p):
  if i > 0 and p[i]-p[i-1] < ans:
    ans = p[i]-p[i-1]

print(ans)



n=int(input())
a=list(map(int, input().split()))
min_a = min(a)
ans = 1000000000000000000
prev_idx = -1000000000000000
for i in range(n):
	if a[i] == min_a:
		ans = min(ans, i-prev_idx)
		prev_idx = i
print(ans)