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: EASY
Tags: Implementation

Starter code:

Solutions:
n = int(input())
a = list(map(int, input().split()))
min = min(a)
ans = []
for i in range(n):
	if a[i] == min:
		ans.append(i)
now = 9999999
for i in range(1, len(ans)):
	if ans[i] - ans[i - 1] < now:
		now = ans[i] - ans[i - 1]
print(now)


length = int(input())
array = [int(r) for r in input().split(' ')]
minimum = min(array)
mindex = []
mindiffdex = []
for i in range(length):
	if array[i] == minimum:
		mindex.append(i)
for i in range(1, len(mindex)):
	mindiffdex.append(mindex[i] - mindex[i - 1])
print(min(mindiffdex))


max = min
n = int(input())
a = [int(x) for x in input().split()]
a = [100000000000] + a + [1000000000000]
f = max(a)
indi = []
for i in range(1, n + 1):
	if a[i] <= a[i + 1] and a[i] <= a[i - 1] and (a[i] == f):
		indi.append(i)
best = 10000000000000000000
for i in range(len(indi) - 1):
	best = max(best, indi[i + 1] - indi[i])
print(best)


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)


import sys
n = int(input())
a = list(map(int, input().split()))
d = dict()
min_v = min(a)
ans = 10 ** 9
for (i, x) in enumerate(a):
	if x == min_v and x in d:
		ans = min(ans, i - d[x])
	d[x] = i
print(ans)


input()
arr = [int(i) for i in input().split()]
arrmin = min(arr)
minpos = [i for (i, item) in enumerate(arr) if item == arrmin]
print(min((minpos[i + 1] - minpos[i] for i in range(len(minpos) - 1))))


def lInt(d=None):
	return 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()))
cur = 0
ans = 100001
for i in range(1, n):
	if a[cur] == a[i]:
		ans = min(ans, i - cur)
		cur = i
	elif a[i] < a[cur]:
		cur = i
		ans = 100001
print(ans)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
a = sorted(list(set([(x + 1) * (a[x] == m) for x in range(n)])))
b = not a[0]
a = [a[x] - a[x - 1] for x in range(1, len(a))]
print(min(a[b:]))


from sys import maxsize
n = int(input())
arr = list(map(int, input().split()))
m = maxsize
res = maxsize
ind = []
for i in range(len(arr)):
	if arr[i] < m:
		m = arr[i]
		ind = [i]
		res = maxsize
	elif arr[i] == m:
		ind.append(i)
		if ind[-1] - ind[-2] < res and len(ind) > 1:
			res = ind[-1] - ind[-2]
print(res)


n = int(input())
q = [int(x) for x in input().split()]
idx = dict()
vmin = int(9000000000.0)
for i in range(n):
	vmin = min(vmin, q[i])
	if q[i] not in idx.keys():
		idx[q[i]] = []
	idx[q[i]].append(i)
idx[vmin].sort()
ans = int(9000000000.0)
for i in range(len(idx[vmin]) - 1):
	ans = min(ans, abs(idx[vmin][i] - idx[vmin][i + 1]))
print(ans)


input()
arr = list(map(int, input().split()))
m = min(arr)
idx = [i for (i, x) in enumerate(arr) if x == m]
print(min((idx[i + 1] - idx[i] for i in range(len(idx) - 1))))


n = int(input())
arr = [int(i) for i in input().strip().split()]
number = min(arr)
brr = []
for i in range(n):
	if arr[i] == number:
		brr.append(i)
for i in range(len(brr) - 1, 0, -1):
	brr[i] = brr[i] - brr[i - 1]
brr[0] = 999999999999
print(min(brr))


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


from sys import stdin

def solve(n, l):
	ocur = {}
	min__ = float('inf')
	for i in range(n):
		if ocur.get(l[i]) != None:
			ocur[l[i]].append(i)
		else:
			min__ = min(min__, l[i])
			ocur[l[i]] = [i]
	min_arr = ocur.get(min__)
	ans = float('inf')
	for j in range(len(min_arr) - 1):
		ans = min(ans, min_arr[j + 1] - min_arr[j])
	return ans

def main():
	n = int(stdin.readline().strip())
	l = [int(x) for x in stdin.readline().split()]
	print(solve(n, l))
main()


n = int(input())
a = list(map(int, input().split()))
m = n
mi = min(a)
now = 0
s = False
for i in a:
	if i == mi:
		if s is True:
			if now < m:
				m = now
		now = 0
		s = True
	elif s is True:
		now += 1
print(m + 1)


n = int(input())
A = list(map(int, input().split()))
m = 10 ** 9 + 1
mi = []
for i in range(len(A)):
	x = A[i]
	if x < m:
		mi = []
		m = x
	if x == m:
		mi.append(i)
md = 10 ** 5 + 1
for i in range(1, len(mi)):
	if mi[i] - mi[i - 1] < md:
		md = mi[i] - mi[i - 1]
print(md)


R = lambda : list(map(int, input().split()))
n = int(input())
a = R()
x = min(a)
min_d = 9999999999999999999
cnt = 0
for i in range(n):
	if a[i] == x:
		try:
			tmp = a.index(x, i + 1)
			min_d = min(tmp - i, min_d)
			i = tmp
		except ValueError:
			break
print(min_d)


n = int(input())
arr = [int(item) for item in input().split()]
mini = 10 ** 9 + 1
for j in arr:
	if j < mini:
		mini = j
i = -1
j = -1
flag = 0
count = 10 ** 9 + 1
for k in range(n):
	if arr[k] == mini and flag == 0:
		flag = 1
		i = k
		continue
	if arr[k] == mini and flag == 1:
		if count > k - i:
			count = k - i
		i = k
print(count)


n = int(input())
l = list(map(int, input().split()))
x = min(l)
k = l.index(x)
dmin = n + 1
for i in range(k + 1, n):
	if l[i] == x:
		d = i - k
		k = i
		if d < dmin:
			dmin = d
print(dmin)


from pprint import pprint as pp

def GI():
	return int(input())

def GIS():
	return map(int, input().split())

def main():
	input()
	a = list(GIS())
	m = min(a)
	last_min_index = None
	min_dist = len(a) + 1
	for (i, d) in enumerate(a):
		if d != m:
			continue
		if last_min_index is not None:
			min_dist = min([i - last_min_index, min_dist])
		last_min_index = i
	print(min_dist)
main()


from sys import maxsize
n = int(input())
arr = list(map(int, input().split()))
(mini, m) = (min(arr), maxsize)
idx = []
for (i, ele) in enumerate(arr):
	if ele == mini:
		idx.append(i)
for i in range(len(idx)):
	if i != len(idx) - 1:
		t = idx[i + 1] - idx[i]
		if t < m:
			m = t
print(m)


input()
a = list(map(int, input().split()))
am = min(a)
d = [k for (k, v) in enumerate(a) if v == am]
print(min([d2 - d1 for (d1, d2) in zip(d[:-1], d[1:])]))


n = int(input())
ara = [int(i) for i in input().split()]
(mn, ans, pos) = (min(ara), 1000000000000, -100000000000)
for i in range(n):
	if ara[i] == mn:
		ans = min(ans, i - pos)
		pos = i
print(ans)


n = int(input())
lst = []
for x in input().split():
	lst.append(int(x))
mini = min(lst)
ls = lst.index(mini)
l = len(lst)
for x in range(ls + 1, len(lst)):
	if lst[x] == mini:
		l = min(l, x - ls)
		ls = x
print(l)


n = int(input())
a = [int(x) for x in input().split()]
minv = a[0]
minDist = n
minInd = 0
for i in range(1, len(a)):
	if a[i] < minv:
		minv = a[i]
		minInd = i
		minDist = n
	elif a[i] == minv:
		minDist = min(minDist, i - minInd)
		minInd = i
print(minDist)


inp = input()
inp2 = input().split(' ')
l = []
for item in inp2:
	l.append(int(item))
minimum = min(l)
minlist = []
i = 0
while i < len(l):
	if l[i] == minimum:
		minlist.append(i)
	i += 1
i = 0
abslist = []
while i < len(minlist) - 1:
	abslist.append(minlist[i + 1] - minlist[i])
	i += 1
print(min(abslist))


def arr_enu():
	return [[i, int(x)] for (i, x) in enumerate(stdin.readline().split())]
from sys import stdin
(n, a) = (int(input()), sorted(arr_enu(), key=lambda x: x[1]))
(mi, ans) = (a[0][1], float('inf'))
for i in range(1, n):
	if a[i][1] == mi:
		ans = min(ans, a[i][0] - a[i - 1][0])
	else:
		break
print(ans)


n = int(input())
a = list(map(int, input().split()))
ans = -1
r = 0
mn = min(a)
for i in range(n):
	if a[i] == mn:
		if ans == -1:
			r = 0
			ans = 0
		elif ans == 0:
			ans = r
		elif r <= ans:
			ans = r
		r = 0
	r += 1
print(ans)


numofnums = int(input())
numbers = input().split(' ', numofnums)
for i in range(numofnums):
	numbers[i] = int(numbers[i])
x = min(numbers)
x1 = 0
x2 = 0
for i in range(numofnums - 1, -1, -1):
	if numbers[i] == x:
		x2 = i
res = numofnums + 1
for i in range(x2 + 1, numofnums):
	if numbers[i] == x:
		x1 = x2
		x2 = i
		if x2 - x1 < res:
			res = x2 - x1
print(res)


inp = int(input())
item = list(map(int, input().split()))
m = min(item)
lis = []
for x in range(inp):
	if item[x] == m:
		lis.append(x)
lislen = len(lis)
for x in range(lislen - 1):
	if x == 0 and lislen > 1:
		mindis = abs(lis[x] - lis[x + 1])
	else:
		temp = abs(lis[x] - lis[x + 1])
		if mindis > temp:
			mindis = temp
print(mindis)


R = lambda : map(int, input().split())
INF = float('inf')
(n, lst) = (int(input()), R())
(minum, L) = (INF, [])
for (i, x) in enumerate(lst):
	if x < minum:
		minum = x
		L = [i]
	elif x == minum:
		L.append(i)
print(min((j - i for (i, j) in zip(L[:-1], L[1:]))))


n = int(input())
a = list(map(int, input().split()))
m = min(a)
(cm, dis) = (0, 1000000)
lm = a.index(min(a))
for i in range(lm + 1, len(a)):
	if a[i] == m:
		if i - lm < dis:
			dis = i - lm
		lm = i
print(dis)


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


n = int(input())
a = [int(i) for i in input().split()]
mn = min(a)
ans = []
for i in range(len(a)):
	if a[i] == mn:
		ans.append(i)
ans.sort()
mi = 10 ** 9 + 9
for i in range(len(ans) - 1):
	mi = min(mi, ans[i + 1] - ans[i])
print(mi)


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


def main():
	from sys import stdin, stdout
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	minim = min(arr)
	my_l = []
	for (i, j) in enumerate(arr):
		if j == minim:
			my_l.append(i)
	my_l_ = []
	for i in range(1, len(my_l)):
		my_l_.append(my_l[i] - my_l[i - 1])
	stdout.write(str(min(my_l_)))
main()


n = int(input())
a = list(map(int, input().split()))
m = min(a)
v = list((i for i in range(n) if a[i] == m))
print(min((y - x for (x, y) in zip(v, v[1:]))))


n = int(input())
a = list(map(int, input().split()))
mn = 10 ** 9 + 1
ran = n + 1
pos = 0
for i in range(n):
	if a[i] < mn:
		pos = i
		mn = a[i]
		ran = n + 1
	elif a[i] == mn:
		ran = min(ran, i - pos)
		pos = i
print(ran)


def main():
	n = int(input())
	a = [int(c) for c in input().split()]
	_min = min(a)
	pos = [i for (i, e) in enumerate(a) if e == _min]
	ans = len(a) - 1
	for i in range(1, len(pos)):
		cur = pos[i] - pos[i - 1]
		if cur == 1:
			print(1)
			return
		if cur < ans:
			ans = cur
	print(ans)
main()


n = int(input())
l = list(input().split())
a = int(l[0])
for i in range(1, n):
	if int(l[i]) < int(a):
		a = l[i]
v = list()
for i in range(n):
	if int(l[i]) == int(a):
		b = i
		break
for i in range(b + 1, n):
	if int(l[i]) == int(a):
		v.append(i - b)
		b = i
print(min(v))


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())
l = [int(x) for x in input().split()]
mn = min(l)
prev = None
ans = n
for i in range(n):
	if l[i] == mn:
		if prev is not None:
			ans = min(ans, i - prev)
		prev = i
print(ans)


n = int(input())
mas = list(map(int, input().split()))
gas = []
f = min(mas)
for i in range(n):
	if mas[i] == f:
		gas.append(i)
otv = 10000000000000
for i in range(len(gas) - 1):
	if gas[i + 1] - gas[i] < otv:
		otv = gas[i + 1] - gas[i]
print(otv)


n = int(input())
nums = [int(x) for x in input().split()]
minimum = min(nums)
minimums_index = []
for i in range(len(nums)):
	if nums[i] == minimum:
		minimums_index.append(i)
shortest_distance = 10 ** 1000
for i in range(len(minimums_index) - 1, 0, -1):
	if minimums_index[i] - minimums_index[i - 1] < shortest_distance:
		shortest_distance = minimums_index[i] - minimums_index[i - 1]
print(shortest_distance)


import bisect

def list_output(s):
	print(' '.join(map(str, s)))

def list_input(s='int'):
	if s == 'int':
		return list(map(int, input().split()))
	elif s == 'float':
		return list(map(float, input().split()))
	return list(map(str, input().split()))
n = int(input())
a = list(map(int, input().split()))
amin = min(a)
pre = -1
res = int(1000000000.0)
for i in range(n):
	if a[i] == amin:
		if pre > -1:
			res = min(res, i - pre)
		pre = i
print(res)


import math
n = int(input())
arr = list(map(int, input().split()))
min_num = min(arr)
res = list()
index = 0
for num in range(n):
	if arr[num] == min_num:
		res.append(index)
	index += 1
res_num = math.inf
for num in range(1, len(res)):
	res_num = min(res_num, res[num] - res[num - 1])
print(res_num)


n = int(input())
l = list(map(int, input().split()))
m = min(l)
x = n
y = -n
for (i, j) in enumerate(l):
	if j == m:
		x = min(x, i - y)
		y = i
print(x)


_ = int(input())
A = list(map(int, input().split()))
xmin = min(*A)
index = []
for i in range(len(A)):
	if A[i] == xmin:
		index.append(i)
m = []
for i in range(len(index) - 1):
	m.append(index[i + 1] - index[i])
print(min(m))


n = int(input())
arr = list(map(int, input().split()))
minK = 1000000000.0 + 1
for i in range(n):
	minK = min([minK, arr[i]])
step = 0
toggle = False
result = []
for i in range(n):
	step += 1
	if arr[i] == minK:
		if toggle == True:
			result.append(step)
		else:
			toggle = True
		step = 0
minK = 1000000000.0 + 1
for i in range(len(result)):
	minK = min([result[i], minK])
print(minK)


n = int(input())
a = [int(i) for i in input().split()]
(mx, d) = (0, 10 ** 5 + 1)
for i in range(1, n):
	if a[i] < a[mx]:
		mx = i
		d = 10 ** 5 + 1
		continue
	if a[i] == a[mx]:
		d = min(d, i - mx)
		mx = i
print(d)


import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def def_value():
	return 0

def time_lagbe(n, k, t):
	if n == 0:
		return 0
	if k > n:
		return t
	time1 = n // k * t + n % k * t
	return time1
n = inp()
a = inlist()
mn = min(a)
b = []
for i in range(n):
	if a[i] == mn:
		b.append(i)
min_dis = 100000000000
for i in range(len(b) - 1):
	if b[i + 1] - b[i] < min_dis:
		min_dis = b[i + 1] - b[i]
print(min_dis)


def main():
	N = int(input())
	A = tuple(map(int, input().split()))
	min_ = min(A)
	idx = [i for (i, x) in enumerate(A) if x == min_]
	dist = float('inf')
	for i in range(1, len(idx)):
		dist = min(idx[i] - idx[i - 1], dist)
	print(dist)
main()


import sys
n = int(input())
l = list(map(int, input().split()))
m = min(l)
indices = [i for (i, x) in enumerate(l) if x == m]
mi = sys.maxsize
for i in range(len(indices) - 1):
	x = indices[i + 1] - indices[i]
	if x < mi:
		mi = x
print(mi)


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)
O = True
main = []
for i in range(N):
	if A[i] == x and O:
		sta = i
		O = False
	elif A[i] == x:
		main.append(i - sta)
		sta = i
print(min(main))


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


out = stop = int(input())
input = input().split(' ')
input = list(map(int, input))
strt = 0
minx = min(input)
i_minx1 = input.index(minx)
for i in range(input.count(minx) - 1):
	strt = i_minx1 + 1
	i_minx2 = input.index(minx, strt, stop)
	if i_minx2 - i_minx1 < out:
		out = i_minx2 - i_minx1
	i_minx1 = i_minx2
print(out)


n = int(input())
l = input()
l = [int(i) for i in l.split()]
x = min(l)
t = 0
ans = 0
r = 0
for i in range(len(l)):
	if l[i] == x and t == 0:
		r = i
		t = 1
	elif l[i] == x and t == 1:
		if ans == 0:
			ans = i - r
		else:
			ans = min(i - r, ans)
		r = i
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
mi = 11 ** 9
c = 0
res = []
for i in range(n):
	c += 1
	if a[i] == mi:
		res.append(c)
		c = 0
	elif a[i] < mi:
		c = 0
		mi = a[i]
		res = []
print(min(res))


n = int(input(''))
a = [int(x) for x in input().split()]
p = min(a)
q = a.index(p)
diff = n
for i in range(q + 1, n):
	if a[i] == p:
		c = i - q
		q = i
		if diff > c:
			diff = c
print(diff)


q = int(input())
a = list(map(int, input().split()))
m = min(a)
nn = q
tt = a.index(m)
for i in range(tt + 1, q):
	if a[i] == m:
		if i - tt < nn:
			nn = i - tt
		tt = i
print(nn)


N = int(input())
a = []
line = input().strip().split()
for j in range(N):
	a.append(int(line[j]))
m = min(a)
ml = N
isFirst = True
(first, sec) = (0, 0)
for i in range(N):
	if m == a[i]:
		if isFirst:
			first = i
			sec = i
			isFirst = False
		else:
			first = sec
			sec = i
			ml = min(ml, sec - first)
print(ml)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
k = a.index(m)
b = []
c = 0
for i in range(k + 1, n):
	if a[i] == m:
		b.append(c)
		c = 0
	else:
		c = c + 1
print(min(b) + 1)


m = int(input())
l = list(map(int, input().split()))
p = min(l)
b = []
j = 10 ** 9
for i in range(len(l)):
	if l[i] == p:
		b.append(i)
for i in range(len(b) - 1):
	if b[i + 1] - b[i] < j:
		j = b[i + 1] - b[i]
print(j)


h = input()
array = list(map(int, input().split()))
minim = min(array)
indices = []
i = 0
while i < len(array):
	if array[i] == minim:
		indices.append(i)
	i += 1
i = 0
res = []
while i < len(indices) - 1:
	res.append(abs(indices[i] - indices[i + 1]))
	i += 1
print(min(res))


n = int(input())
l = []
y = []
p = input().split(' ')
for i in range(n):
	l.append(int(p[i]))
e = l[:]
e.sort()
w = l.index(e[0])
t = 1
for i in range(w + 1, len(l)):
	if l[i] != e[0]:
		t = t + 1
	else:
		y.append(t)
		t = 1
y.sort()
print(y[0])


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


length = int(input())
nums = input().split(' ')
nums = [int(nums[i]) for i in range(length)]
res = sorted(nums)
smallest = res[0]
counter = 0
marks = []
for i in range(length):
	if nums[i] == smallest:
		marks.append(i)
marks.sort()
dists = []
length_marks = len(marks) - 1
for i in range(length_marks):
	temp = marks[i + 1] - marks[i]
	dists.append(temp)
print(min(dists))


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


N = int(input())
L = list(map(int, input().split(' ')))
H = min(L)
Y = L.index(H)
R = Y
U = 1000000000
for i in range(R + 1, N):
	if L[i] == H:
		Y1 = i
		W = Y1 + 1 - (Y + 1)
		if W < U:
			U = W
			Y = Y1
		else:
			Y = Y1
print(U)


n = int(input())
a = [int(i) for i in input().split()]
m = min(a)
j = None
b = []
ans = 1000000
for i in range(n):
	if a[i] == m:
		b.append(i)
for i in range(1, len(b)):
	ans = min(ans, b[i] - b[i - 1])
print(ans)


size = int(input())
a = input().split()
m = int(a[0])
count = 1
mcount = 0
for i in range(1, size):
	a[i] = int(a[i])
	if a[i] > m:
		count = count + 1
	elif a[i] == m and (count < mcount or mcount == 0):
		mcount = count
		count = 1
	elif a[i] == m and count > mcount:
		count = 1
	elif a[i] < m:
		m = a[i]
		count = 1
		mcount = 0
print(mcount)


n = int(input())
nums = [int(x) for x in input().split()]
minimum = min(nums)
minimums_index = [ind for (ind, x) in enumerate(nums) if x == minimum]
shortest_distance = 10 ** 1000
for i in range(len(minimums_index) - 1, 0, -1):
	current_distance = minimums_index[i] - minimums_index[i - 1]
	if current_distance < shortest_distance:
		shortest_distance = current_distance
print(shortest_distance)


n = int(input())
a = [int(x) for x in input().split()]
r = n
mi = a[0]
imin = 0
r = -1
for i in range(1, n):
	if a[i] == a[imin]:
		if r == -1 or i - imin < r:
			r = i - imin
		imin = i
	if a[i] < a[imin]:
		imin = i
		r = -1
print(r)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
m = min(a)
p = [i for (i, v) in enumerate(a) if v == m]
ans = p[1] - p[0]
for i in range(1, len(p)):
	ans = min(ans, p[i] - p[i - 1])
print(ans)


n = int(input())
arr = [int(i) for i in input().split()]
m = None
pos = None
dist = n + 2
for (index, elem) in enumerate(arr):
	if m == None:
		m = elem
		pos = index
	elif elem == m:
		dist = min(dist, index - pos)
		pos = index
	elif elem < m:
		m = elem
		pos = index
		dist = n + 2
print(dist)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	xs = [i for (i, x) in enumerate(a) if x == m]
	ans = min((b - a for (a, b) in zip(xs, xs[1:])))
	print(ans)
main()


n = int(input())
w = list(map(int, input().split()))
d = n
a = w[0] + 1
index1 = 0
for i in range(n):
	if w[i] < a:
		a = w[i]
		index1 = i
		d = n
	elif w[i] == a:
		if i - index1 < d:
			d = i - index1
		index1 = i
print(int(d))


n = int(input())
a = list(map(int, input().split()))
mini = min(a)
first = None
second = None
ans = 999999999999999
for i in range(n):
	if a[i] == mini:
		if first == None:
			first = i
		else:
			second = i
			ans = min(ans, second - first)
			first = second
			second = None
print(ans)


n = int(input())
prev = -10 ** 9
ans = -prev
l = [int(x) for x in input().split()]
minn = min(l)
for i in range(n):
	if l[i] == minn:
		ans = min(ans, i - prev)
		prev = i
print(ans)


t = int(input())
l = list(map(int, input().split()))
p = []
m = min(l)
for i in range(t):
	if l[i] == m:
		p.append(i)
m = p[1] - p[0]
j = 1
while j < len(p) - 1:
	if p[j + 1] - p[j] < m:
		m = p[j + 1] - p[j]
	j += 1
print(m)


n = int(input())
m = list(map(int, input().split()))
a = min(m)
i = m.index(a)
ans = n
for x in range(m.index(a) + 1, n):
	if m[x] == a:
		ans = min(ans, x - i)
		i = x
print(ans)


n = int(input())
mins = []
cmin = 99999999999999999
minsindex = []
count = 0
for i in input().split():
	i = int(i)
	if i <= cmin:
		cmin = i
		mins.append(i)
		minsindex.append(count)
	count += 1
minofmin = min(mins)
i = 0
while i < len(mins):
	if mins[i] != minofmin:
		del mins[i]
		del minsindex[i]
	else:
		i += 1
minlenght = 999999999999999
for i in range(1, len(minsindex)):
	if minsindex[i] - minsindex[i - 1] < minlenght:
		minlenght = minsindex[i] - minsindex[i - 1]
print(minlenght)


n = int(input())
tab = list(map(int, input().split()))
i = tab.index(min(tab))
val = tab[i]
qtab = [i]
for j in range(i + 1, n):
	if tab[j] == val:
		qtab.append(j)
if len(qtab) == 1:
	tabx = list(tab)
	tabx.pop(i)
	val = min(tabx)
	j = tab.index(val)
	qt = [j]
	mn = abs(j - qtab[0])
	for u in range(n):
		if tab[u] == val:
			mn = min(mn, abs(u - qtab[0]))
	print(mn)
else:
	mn = qtab[1] - qtab[0]
	for i in range(2, len(qtab)):
		mn = min(mn, qtab[i] - qtab[i - 1])
	print(mn)


n = int(input())
l = list(map(int, input().split()))
m = min(l)
ans = []
if l.count(m) > 1:
	for i in range(n):
		if l[i] <= m:
			m = l[i]
			ans.append(i)
	ans = sorted(ans)
	a = 10 ** 9
	for i in range(1, len(ans)):
		if abs(ans[i] - ans[i - 1]) < a:
			a = abs(ans[i] - ans[i - 1])
	print(a)
else:
	m1 = l.index(min(l))
	l.pop(min(l))
	m2 = l.index(min(l))
	if abs(m1 - m2) == 0:
		print('1')
	else:
		print(abs(m1 - m2))


def main():
	input()
	arr = list(map(int, input().split()))
	minV = min(arr)
	indexes = [i for (i, v) in enumerate(arr) if v == minV]
	print(min((indexes[i + 1] - indexes[i] for i in range(0, len(indexes) - 1))))
main()


n = int(input())
a = list(map(int, input().split()))
x = min(a)
c = [i for i in range(n) if a[i] == x]
d = [c[i] - c[i - 1] for i in range(1, len(c))]
print(min(d))


n = int(input())
myList = list(map(int, input().split()))
minimum = min(myList)
rememberDist = []
currentMinimum = len(myList)
oldMinimum = len(myList)
counter = 0
for i in range(0, n):
	if myList[i] == minimum:
		counter += 1
		if counter == 1:
			currentMinimum = i
		if counter > 1:
			oldMinimum = currentMinimum
			currentMinimum = i
			rememberDist.append(currentMinimum - oldMinimum)
print(min(rememberDist))


n = int(input())
a = list(map(int, input().split()))
b = min(a)
c = a.index(b)
ans = []
for i in range(c + 1, n):
	if a[i] == b:
		ans.append(i - c)
		c = i
print(min(ans))


n = int(input())
str1 = input()
list1 = str1.split()
list1 = [int(item) for item in list1]
min1 = min(list1)
list2 = []
list3 = []
for i in range(len(list1)):
	if list1[i] == min1:
		list2.append(i)
for i in range(len(list2) - 1):
	list3.append(list2[i + 1] - list2[i])
c = min(list3)
print(c)


n = int(input())
A = list(map(int, input().split()))
min1 = min(A)
ans1 = 0
ans2 = 0
ans1 = A.index(min1)
ans = 10000000
for q in range(ans1 + 1, n):
	if A[q] == min1:
		ans = min(ans, q - ans1)
		ans1 = q
print(ans)


def main():
	input()
	arr = list(map(int, input().split()))
	k = min(arr)
	ak = []
	for i in range(len(arr)):
		if arr[i] == k:
			ak.append(i)
	ak.sort()
	r = len(arr)
	for i in range(len(ak) - 1):
		r = min(r, ak[i + 1] - ak[i])
	return r
print(main())


n = int(input())
data = list(map(int, input().split()))
m = min(data)
save = data.index(m)
ans = 1000000000.0
for i in range(save + 1, n):
	if data[i] == m:
		ans = min(ans, i - save)
		save = i
print(ans)


n = int(input())
a = list(map(int, input().split()))
minimum = min(a)
(r, last) = (n, a.index(minimum))
for i in range(last + 1, n):
	if a[i] == minimum:
		r = min(r, i - last)
		last = i
print(r)


n = int(input())
l = list(map(int, input().split()))
m = min(l)
s = []
for i in range(n):
	if l[i] == m:
		s.append(i)
s.sort()
m = 10 ** 18
for i in range(1, len(s)):
	m = min(m, s[i] - s[i - 1])
print(m)


from math import *
from bisect import *
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(1):
	n = I()
	a = LI()
	b = min(a)
	c = -1
	d = -1
	ans = n
	for i in range(n):
		if c == -1 and b == a[i]:
			c = i
		elif d == -1 and b == a[i]:
			d = i
		elif b == a[i]:
			c = d
			d = i
		if c > -1 and d > -1:
			ans = min(ans, d - c)
	print(ans)


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())
m = []
sv = -1
indexs = {}
s = list(map(int, input().split()))
for i in range(n):
	a = s[i]
	if sv == -1 or a < sv:
		sv = a
	m.append(a)
	if a not in indexs:
		indexs[a] = [i]
	else:
		indexs[a].append(i)
it = indexs[sv]
min_dist = it[1] - it[0]
for i in range(len(it) - 1):
	if it[i + 1] - it[i] < min_dist:
		min_dist = it[i + 1] - it[i]
print(min_dist)


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())
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())
a = list(map(int, input().split()))
ma = min(a)
aa = [i for i in range(n) if a[i] == ma]
print(min([aa[i + 1] - aa[i] for i in range(len(aa) - 1)]))


N = int(input())
numbers = list(zip(map(int, input().split()), range(N)))
least = min([x[0] for x in numbers])
numbers.sort(key=lambda x: x[1])
numbers.sort(key=lambda x: x[0])
num = list(filter(lambda x: x[0] == least, numbers))
minimum_dist = len(numbers)
for i in range(len(num) - 1):
	x = num[i + 1][1] - num[i][1]
	if minimum_dist > x:
		minimum_dist = x
print(minimum_dist)


n = int(input())
arr = list(map(int, input().split()))
index = []
m = min(arr)
for i in range(0, n):
	if arr[i] == m:
		index.append(i)
d = 999999999999
for i in range(0, len(index) - 1):
	d = min(d, abs(index[i] - index[i + 1]))
print(d)


n = int(input())
s = input()
a = []
s = s.split()
mn = 1000000001
count = 0
minres = 100000
for c in s:
	if int(c) < mn:
		mn = int(c)
		minres = 100000
		count = 0
	if count != 0 and int(c) == mn:
		if count < minres:
			minres = count
		count = 0
	count += 1
print(minres)


n = int(input())
a = [int(i) for i in input().split()]
mn = min(a)
a = [i for (i, val) in enumerate(a) if val == mn]
mn = float('inf')
for i in range(len(a) - 1):
	mn = min(mn, a[i + 1] - a[i])
print(mn)


import sys
import math
import collections
from pprint import pprint as pp
mod = 1000000007
MAX = 10 ** 18

def array():
	return list(map(int, input().split()))

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat
n = int(input())
a = array()
mn = min(a)
ans = MAX
indx = -1
for i in range(n):
	if a[i] == mn:
		indx = i
		break
for i in range(indx + 1, n):
	if a[i] == mn:
		ans = min(ans, i - indx)
		indx = i
print(ans)


n = int(input())
seq = list(map(int, input().split(' ')))
minimum = min(seq)
prev = -1
min_distance = n
for (i, c) in enumerate(seq):
	if c == minimum:
		if prev != -1 and i - prev < min_distance:
			min_distance = i - prev
		prev = i
print(min_distance)


import sys
input = sys.stdin.readline
n = int(input())
a = [int(o) for o in input().split()]
mn = min(a)
b = [i for (i, v) in enumerate(a) if v == mn]
ans = 10 ** 9
for i in range(0, len(b) - 1):
	ans = min(ans, b[i + 1] - b[i])
print(ans)


n = int(input())
A = list(map(int, input().split()))
m = min(A)
R = []
ans = n + 7
for i in range(n):
	if A[i] == m:
		R.append(i)
for i in range(len(R) - 1):
	if R[i + 1] - R[i] < ans:
		ans = R[i + 1] - R[i]
print(ans)


n = int(input())
x = input().split()
y = []
for i in x:
	y.append(int(i))
num = min(y)
ind = []
for i in range(n):
	if y[i] == num:
		ind.append(i)
gap = 1000000
for i in range(1, len(ind)):
	if ind[i] - ind[i - 1] < gap:
		gap = ind[i] - ind[i - 1]
print(gap)


arr_len = int(input())
arr = [int(x) for x in input().split(' ')]
min_num = min(arr)
min_length = len(arr)
len_dict = dict()
for i in range(len(arr)):
	if arr[i] == min_num:
		if arr[i] not in len_dict.keys():
			len_dict[min_num] = i
		else:
			if i - len_dict[min_num] < min_length:
				min_length = i - len_dict[min_num]
			len_dict[min_num] = i
print(min_length)


def li():
	return list(map(int, input().split()))
n = int(input())
a = li()
l = -1
t = min(a)
ans = 1000000000
for i in range(len(a)):
	if a[i] == t:
		if l == -1:
			l = i
		else:
			ans = min(i - l, ans)
			l = i
print(ans)


n = int(input())
z = list(map(int, input().split()))
for i in range(n):
	z[i] = [z[i], i]
z.sort()
ans = 1000000000.0
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())
a = [x for x in map(int, input().split())][:n]
m = min(a)
ind1 = a.index(m)
small = 100000
for i in range(ind1 + 1, len(a)):
	if a[i] == m:
		ind2 = i
		if small > ind2 - ind1:
			small = ind2 - ind1
		ind1 = ind2
print(small)


n = int(input())
idx___val = [int(x) for x in input().split()]
minim = min(idx___val)
min_idxes = [idx for idx in range(n) if idx___val[idx] == minim]
min_dist = min([min_idxes[i] - min_idxes[i - 1] for i in range(1, len(min_idxes))])
print(min_dist)


input()
A = list(map(int, input().split()))
a_min = min(A)
X = [i for (i, a) in enumerate(A) if a == a_min]
print(min((i - j for (i, j) in zip(X[1:], X))))


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


n = int(input())
b = input()
a = list(map(int, b.split()))
m = min(a)
cnt = 0
razn = []
for i in range(len(a)):
	if a[i] == m:
		cnt += 1
		if cnt == 1:
			ind1 = i
		elif cnt >= 2:
			ind2 = i
			razn.append(ind2 - ind1)
			ind1 = ind2
print(min(razn))


n = int(input())
a = list(map(int, input().split()))
m = min(a)
i = a.index(m)
b = []
for j in range(i + 1, n):
	if a[j] == m:
		b.append(j - i)
		i = j
print(min(b))


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 = int(input())
a = list(map(int, input().split()))
m = min(a)
pos = []
for i in range(n):
	if a[i] == m:
		pos.append(i)
x = 99999999999
for i in range(len(pos) - 1):
	if x > min(x, abs(pos[i + 1] - pos[i])):
		x = abs(pos[i + 1] - pos[i])
print(x)


n = int(input())
a = [int(x) for x in input().split()]
b = min(a)
c = a.index(b)
co = a.count(b)
p = 1
ans = 900000
for i in range(c + 1, n):
	if a[i] == b:
		tans = i - c
		c = i
		if tans < ans:
			ans = tans
		p += 1
		if p == co:
			break
print(ans)


n = int(input())
a = list(map(int, input().split(' ')))
l = min(a)
ar = []
for i in range(len(a)):
	if a[i] == l:
		ar.append(i + 1)
for i in range(1, len(ar)):
	ar[i - 1] = ar[i] - ar[i - 1]
ar.pop()
print(min(ar))


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
n = int(input())
a = list(rint())
b = []
for i in range(n):
	b.append([a[i], i])
b.sort()
min_val = b[0][0]
c = []
for i in range(n):
	if b[i][0] == min_val:
		c.append(b[i][1])
min_dist = 10 ** 100
for i in range(len(c) - 1):
	i1 = c[i]
	i2 = c[i + 1]
	dist = c[i + 1] - c[i]
	if dist < min_dist:
		min_dist = dist
print(min_dist)


import math
R = lambda : map(int, input().split())
n = int(input())
a = list(R())
x = min(a)
indices = [i for i in range(n) if a[i] == x]
l = indices[0]
r = indices[1]
for i in range(2, len(indices)):
	if indices[i] - indices[i - 1] < r - l:
		l = indices[i - 1]
		r = indices[i]
print(r - l)


from collections import defaultdict
MyDict = defaultdict(list)
input()
X = list(map(int, input().split()))
for i in range(len(X)):
	MyDict[X[i]].append(i)
for i in sorted(MyDict.keys()):
	if len(MyDict[i]) > 1:
		Temp = sorted(MyDict[i])
		print(min((Temp[j] - Temp[j - 1] for j in range(1, len(Temp)))))
		exit()


n = int(input())
data = list(map(int, input().split()))
mini = None
lastMiniIdx = None
distOfMins = 10000000
for (idx, val) in enumerate(data):
	if mini is None:
		mini = val
		lastMiniIdx = idx
	elif mini == val:
		distOfMins = min(idx - lastMiniIdx, distOfMins)
		lastMiniIdx = idx
	elif mini > val:
		mini = val
		lastMiniIdx = idx
		distOfMins = 10000000
print(distOfMins)


n = int(input())
l = list(map(int, input().strip().split()))
x = min(l)
y = []
for (a, b) in enumerate(l):
	if b == x:
		y.append(a)
z = []
for i in range(len(y) - 1):
	t = y[i + 1] - y[i]
	z.append(t)
print(min(z))


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ''.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base=3):
	newnumber = ''
	while number > 0:
		newnumber = str(number % base) + newnumber
		number //= base
	return newnumber
n = ii()
a = li()
mina = min(a)
ans = n
pos = a.index(mina)
for i in range(pos + 1, n):
	if a[i] == mina:
		ans = min(ans, i - pos)
		pos = i
print(ans)


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())
arr = list(map(int, input().split(' ')))
minimum = min(arr)
dest = []
for i in range(len(arr)):
	if arr[i] == minimum:
		dest.append(i)
result = []
for i in range(len(dest) - 1):
	result.append(dest[i + 1] - dest[i])
print(min(result))


n = int(input())
m = list(map(int, input().split()))
s = min(m)
g = 0
for i in range(n):
	if m[i] == s:
		g = i
		break
ans = 10 ** 10
for i in range(g + 1, n):
	if m[i] == s:
		ans = min(ans, i - g)
		g = i
print(ans)


n = int(input())
nums = [int(x) for x in input().split()]
minimum = min(nums)
indexes = [ind for (ind, x) in enumerate(nums) if x == minimum]
distances = [indexes[i + 1] - indexes[i] for i in range(len(indexes) - 1)]
print(min(distances))


n = int(input())
a = [int(s) for s in input().split()]
b = []
q = min(a)
for i in range(len(a)):
	if a[i] == q:
		b.append(i)
q = b[1] - b[0]
for i in range(len(b) - 1):
	if b[i + 1] - b[i] < q:
		q = b[i + 1] - b[i]
print(q)


n = int(input())
a = list(map(int, input().split()))
if n == 2:
	print(1)
else:
	k = min(a)
	l = []
	for i in range(n):
		if a[i] == k:
			l.append(i)
	ll = []
	for i in range(1, len(l)):
		ll.append(l[i] - l[i - 1])
	print(min(ll))


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest
from copy import deepcopy
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))

def inps():
	return sys.stdin.readline()

def inpsl(x):
	tmp = sys.stdin.readline()
	return list(tmp[:x])

def err(x):
	print(x)
	exit()
n = inp()
a = inpl()
mi = min(a)
pre = -INF
res = INF
for (i, x) in enumerate(a):
	if x == mi:
		res = min(res, i - pre)
		pre = i
print(res)


def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))
from collections import defaultdict, deque, Counter
from sys import exit
import math
import copy
from bisect import bisect_right
import sys
sys.setrecursionlimit(1000000)
import heapq
INF = 10 ** 10

def dijkstra(graph, start, n):
	h = []
	heapq.heappush(h, (0, start))
	costs = [INF for _ in range(n)]
	while h:
		(cost, cur) = heapq.heappop(h)
		if costs[cur] != INF:
			continue
		costs[cur] = cost
		for edge in graph[cur]:
			(ecost, tgt) = edge
			if costs[tgt] == INF:
				heapq.heappush(h, (cost + ecost, tgt))
	return costs

def main():
	n = getN()
	nums = getList()
	mn = min(nums)
	prev = -10000000000
	ans = 100000000000000
	for (i, num) in enumerate(nums):
		if num == mn:
			dist = i - prev
			if ans > dist:
				ans = dist
			prev = i
	print(ans)
main()


import sys
n = int(input())
a = [int(i) for i in input().split()]
i = a.index(min(a))
m = i
i += 1
mi = sys.maxsize
while i < n:
	if a[i] == a[m]:
		s = i - m
		if s < mi:
			mi = s
		m = i
	i += 1
print(mi)


n = int(input())
a = [int(i) for i in input().split()]
(ci, m, ans) = (-200000, min(a), 200000)
for i in range(n):
	if a[i] == m:
		ans = min(ans, i - ci)
		ci = i
print(ans)


n = int(input())
s = list(map(int, input().split()))
m = min(s)
cmd = len(s)
pr = s.index(m)
f = pr
for (i, e) in enumerate(s):
	if m == e:
		if i - pr == 0:
			continue
		cmd = min(cmd, abs(i - pr))
		pr = i
print(cmd)


n = int(input())
a = list(map(int, input().split()))
sta = []
min = 10 ** 9 + 1
for i in range(n):
	if a[i] < min:
		sta.clear()
		min = a[i]
	if a[i] == min:
		sta.append(i)
min = 10 ** 5 + 1
for i in range(1, len(sta)):
	if sta[i] - sta[i - 1] < min:
		min = sta[i] - sta[i - 1]
print(min)


import sys
n = int(input())
v = sorted(((i, int(x)) for (i, x) in enumerate(input().split())), key=lambda item: item[1])
(res, i) = (v[1][0] - v[0][0], 1)
while i < n and v[i][1] == v[i - 1][1]:
	res = min(v[i][0] - v[i - 1][0], res)
	i += 1
print(res)


n = int(input())
list_ = list(map(int, input().split()))
min_ = min(list_)
list_1 = [i for i in range(n) if list_[i] == min_]
print(min((list_1[i + 1] - list_1[i] for i in range(list_1.__len__() - 1))))


N = int(input())
b = []
a = list(map(int, input().strip().split()))
m = min(a)
ml = N
for i in range(N):
	if m == a[i]:
		b.append(i)
lenB = len(b)
for j in range(1, lenB):
	this = b[j] - b[j - 1]
	if ml > this:
		ml = this
print(ml)


n = int(input())
arr = [int(x) for x in input().split()]
min1 = min(arr)
count = arr.count(min1)
index1 = arr.index(min1)
k = 100000000
arr[index1] = k
k += 1
brr = []
for i in range(index1 + 1, len(arr), 1):
	if arr[i] == min1:
		arr[i] = k
		k += 1
		ans = abs(index1 - i)
		brr.append(ans)
		index1 = i
print(min(brr))


import sys
n = int(input())
a = list(map(int, input().split()))
m = min(a)
k = 0
for i in range(len(a)):
	if a[i] == m:
		k = i
		break
r = 1
mn = 1000000000
for i in range(k + 1, n):
	if a[i] == m:
		mn = min(r, mn)
		r = 0
	r += 1
print(mn)


n = input()
arr = [[v, i] for (i, v) in enumerate(list(map(int, input().strip().split())))]
arr.sort()
x = arr[0][0]
i = 0
ans = 10 ** 20
while i + 1 < len(arr) and arr[i + 1][0] == x:
	ans = min(ans, abs(arr[i + 1][1] - arr[i][1]))
	i += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
x = min(a)
ans = 10000000
b = []
for i in range(0, n):
	if a[i] == x:
		b.append(i)
pos = b[0]
for i in range(1, len(b)):
	ans = min(ans, b[i] - pos)
	pos = b[i]
print(ans)


n = int(input())
s = list(map(int, input().split()))
x = min(s)
minval = []
for i in range(len(s)):
	if s[i] == x:
		minval.append(i)
ans = minval[1] - minval[0]
for i in range(1, len(minval)):
	if minval[i] - minval[i - 1] < ans:
		ans = minval[i] - minval[i - 1]
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = min(a)
now = -1
ans = 1000000
for i in range(len(a)):
	if a[i] == b:
		if now != -1:
			ans = min(ans, i - now)
		now = i
print(ans)


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, a) = (int(input()), list(map(int, input().split())))
m = min(a)
v = [i for (i, ai) in enumerate(a) if ai == m]
print(min((v[i + 1] - v[i] for i in range(len(v) - 1))))


n = int(input())
arr = list(map(int, input().split()))
m = min(arr)
first = arr.index(m) + 1
tmp = 1
output = -1
for i in range(first, len(arr)):
	if arr[i] == m:
		if output < 0:
			output = tmp
		else:
			output = min(output, tmp)
		tmp = 1
	else:
		tmp += 1
	if output == 1:
		break
print(output)


n = int(input())
m = list(map(int, input().split()))
s = min(m)
y = n
h = m.index(s)
for i in range(h + 1, y):
	if m[i] == s:
		if i - h < y:
			y = i - h
		h = i
print(y)


n = [int(x) for x in input().split()]
arr = [int(x) for x in input().strip().split()]
minn = arr[0]
record = n[0]
inner_count = 0
for x in range(1, n[0]):
	inner_count += 1
	if arr[x] < minn:
		minn = arr[x]
		inner_count = 0
		record = n[0]
	elif arr[x] == minn:
		if inner_count <= record:
			record = inner_count
		inner_count = 0
print(record)


def get_ints():
	return list(map(int, input().split()))
N = int(input())
a = get_ints()
ans = 2000000000.0
pos = 0
curr = a[0]
for i in range(1, N):
	if a[i] < curr:
		curr = a[i]
		ans = 1000000000.0
		pos = i
	elif a[i] == curr:
		ans = min(ans, i - pos)
		pos = i
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = min(a)
d = 0
f = -1
c = 0
for i in a:
	if i == b:
		if f == -1:
			f = c
		else:
			if c - f < d or d == 0:
				d = c - f
			if d == 1:
				break
			f = c
	c += 1
print(d)


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


n = int(input())
ans = 1061109567
prev = -1061109567
l = [int(x) for x in input().split()]
minn = min(l)
for i in range(n):
	if l[i] == minn:
		ans = min(i - prev, ans)
		prev = i
print(ans)


n = int(input())
array = list(map(int, input().split()))
min_ele = min(array)
index1 = array.index(min_ele)
list_count = []
count = 0
for i in range(index1 + 1, n):
	count += 1
	if array[i] == min_ele:
		list_count.append(count)
		index1 = i
		count = 0
print(min(list_count))


n = int(input())
l1 = []
l1 = input().split()
i = 0
for i in range(n):
	l1[i] = int(l1[i])
l2 = []
l2 = l1[:]
l2.sort()
j = 0
for j in range(n - 1):
	if l2[j] == l2[j + 1]:
		x = l2[j]
		break
st = -1
en = -1
c = 0
d = -1
for c in range(n):
	if l1[c] == x:
		if st == -1:
			st = c
		else:
			if en != -1:
				st = en
			en = c
			if d == -1:
				d = en - st
			elif en - st < d:
				d = en - st
print(d)


n = int(input())
nums = [int(x) for x in input().split()]
minimum = min(*nums)
indices = [i for i in range(n) if nums[i] == minimum]
print(min((r - l for (l, r) in zip(indices, indices[1:]))))


n = int(input())
a = [int(s) for s in input().split()]
m = min(a)
b = []
for i in range(0, n):
	if a[i] == m:
		b.append(i)
mm = n + 1
if len(b) == 1:
	mm = 0
	for i in range(1, n):
		if a[i] == m:
			mm = i
			break
	nm = 0
	if mm == 0:
		nm = 1
	for i in range(0, n):
		if a[i] != m and (a[i] < a[nm] or (a[i] == a[nm] and abs(mm - i) < abs(nm - i))):
			nm = i
	print(mm - nm)
else:
	for i in range(1, len(b)):
		if b[i] - b[i - 1] < mm:
			mm = b[i] - b[i - 1]
	print(mm)


import sys
f = sys.stdin
n = int(f.readline())
s = list(map(int, f.readline().split()))
ans = 10000000000
min_val = 10000000000
min_last_pos = -1
for i in range(n):
	if min_val > s[i]:
		min_val = s[i]
		min_last_pos = i
		ans = 10000000000
	elif min_val == s[i]:
		if ans > i - min_last_pos:
			ans = i - min_last_pos
		min_last_pos = i
print(ans)


n = int(input())
a = list(map(int, input().split()))
ma = min(a)
na = [i for i in range(0, n) if a[i] == ma]
haha = [na[i + 1] - na[i] for i in range(0, len(na) - 1)]
print(min(haha))


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


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

def minrange(u):
	i = 0
	posa = []
	ans = []
	while i != u:
		if a[i] == mina:
			posa.append(i)
		i += 1
	for i in range(len(posa) - 1):
		ans.append(posa[i + 1] - posa[i])
	return min(ans)
print(minrange(n))


nums = input()
ks = list(map(int, input().split()))
min_ks = min(ks)
l = []
for i in range(len(ks)):
	if ks[i] == min_ks:
		l.append(i)
subs = l[1] - l[0]
for i in range(2, len(l)):
	subs = min(subs, l[i] - l[i - 1])
print(subs)


n = int(input())
nums = [int(a) for a in input().strip().split()]
min_num = min(nums)
pre_index = -1
ans = 100000.0 + 1
for index in range(n):
	if nums[index] == min_num:
		if pre_index == -1:
			pre_index = index
		else:
			ans = min(ans, index - pre_index)
			pre_index = index
print(str(ans))


n = int(input())
a = [None] * n
index_min = [None]
sum = 9999999999
a = list(map(int, input().split()))
index_min[0] = a.index(min(a))
for i in range(index_min[0]):
	if a[index_min[0]] == a[i]:
		index_min.append(i)
for i in range(index_min[0] + 1, n):
	if a[index_min[0]] == a[i]:
		index_min.append(i)
for i in range(len(index_min) - 1):
	if sum > index_min[i + 1] - index_min[i]:
		sum = index_min[i + 1] - index_min[i]
print(sum)


n = int(input())
a = [int(i) for i in input().split()]
x = min(a)
arr = []
for h in range(len(a)):
	if a[h] == x:
		arr.append(h)
mini = len(a) - 1
for k in range(len(arr) - 1):
	if arr[k + 1] - arr[k] < mini:
		mini = arr[k + 1] - arr[k]
print(mini)


n = int(input())
l = list(map(int, input().split()))
(m, s, d) = (min(l), n, -n)
for i in range(n):
	if m == l[i]:
		s = min(s, i - d)
		d = i
print(s)


n = int(input())
l = [int(x) for x in input().split()]
m = min(l)
arr = []
for i in range(n):
	if l[i] == m:
		arr.append(i)
n = len(arr)
ans = 1000000
for i in range(1, n):
	if arr[i] - arr[i - 1] < ans:
		ans = arr[i] - arr[i - 1]
print(ans)


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


n = int(input())
a = [int(i) for i in input().split(' ')]
m = min(a)
l = []
result = 10000000000.0 + 7
for i in range(n):
	if a[i] == m:
		l.append(i)
for i in range(len(l) - 1):
	result = min(result, l[i + 1] - l[i])
print(result)


n = int(input())
l = list(map(int, input().split()))
m = min(l)
i = l.index(m) + 1
q = []
count = 0
while i < n:
	if l[i] == m:
		q.append(count)
		count = 0
	else:
		count += 1
	i += 1
print(min(q) + 1)


n = int(input())
a = list(map(int, input().split()))
min_nr = min(a)
searching_second = False
dist = n
count = 0
for it in a:
	if not searching_second:
		count = 0
	else:
		count += 1
	if it == min_nr and searching_second:
		if count - 1 < dist:
			dist = count - 1
		count = 1
	if it == min_nr and (not searching_second):
		count = 1
		searching_second = True
print(dist)


n = int(input())
a = [int(x) for x in input().split()]
mn = min(a)
diff = 1000000000.0
mnpos = None
for i in range(len(a)):
	if a[i] == mn:
		if mnpos is not None:
			diff = min(diff, i - mnpos)
		mnpos = i
print(diff)


def main():
	n = int(input())
	l = list(map(lambda x: int(x), input().split()))
	minimum = sorted(l)[0]
	idx = []
	i = 0
	for i in range(n):
		if l[i] == minimum:
			idx.append(i)
			i += 1
	res = sorted(list(map(lambda x: minus(*x), list(zip(idx[1:], idx[0:-1])))))[0]
	print(res)

def minus(x, y):
	return x - y
main()


n = int(input())
a = input().split()
ls = []
for i in range(len(a)):
	ls.append((int(a[i]), i))
ls = sorted(ls)
ans = 3000300300
mn = ls[0][0]
last = -1
for val in ls:
	if val[0] > mn:
		break
	if last != -1:
		ans = min(ans, val[1] - last)
	last = val[1]
print(ans)


n = int(input())
a = list(map(int, input().split()))
minimum = 10 ** 9
for i in range(n):
	if a[i] < minimum:
		minimum = a[i]
distance = n
index_1 = a.index(minimum)
for i in range(index_1 + 1, n):
	if a[i] == minimum:
		index_2 = i
		if index_2 - index_1 < distance:
			distance = index_2 - index_1
		index_1 = i
print(distance)


def input_ints():
	return list(map(int, input().split()))

def solve():
	input()
	a = input_ints()
	m = min(a)
	ans = 10 ** 10
	p = -1
	for (i, x) in enumerate(a):
		if x == m:
			if p != -1:
				ans = min(ans, i - p)
			p = i
	print(ans)
solve()


n = int(input())
a = list(map(int, input().split()))
M = min(a)
ind = list()
tol = 0
for i in range(n):
	if a[i] == M:
		ind.append(i)
		tol += 1
ma = float('inf')
for i in range(tol - 1):
	ma = min(ma, ind[i + 1] - ind[i])
print(ma)


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))]))


n = int(input())
arr = [int(x) for x in input().split()]
m = arr[0]
dist = 0
pos = 0
for j in range(1, n):
	if arr[j] < m:
		m = arr[j]
		pos = j
		dist = 0
	elif arr[j] == m:
		if j - pos < dist or dist == 0:
			dist = j - pos
		pos = j
print(dist)


class CodeforcesTask911ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.array = []

	def read_input(self):
		self.n = int(input())
		self.array = [int(x) for x in input().split(' ')]

	def process_task(self):
		mn = min(self.array)
		ind = [x for x in range(self.n) if self.array[x] == mn]
		dists = []
		for x in range(len(ind) - 1):
			dists.append(ind[x + 1] - ind[x])
		self.result = str(min(dists))

	def get_result(self):
		return self.result
Solution = CodeforcesTask911ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


def indices(lst, element):
	return [i for (i, val) in enumerate(lst) if val == element]
s = int(input())
a = [int(j) for j in input().split()]
m = min(a)
new = indices(a, m)
b = list()
for i in range(len(new) - 1):
	b.append(new[i + 1] - new[i])
print(min(b))


length = int(input())
a = list(map(int, input().split()))
minimum = min(a)
occurrences = [i for (i, x) in enumerate(a) if x == minimum]
distances = map(lambda x: occurrences[x[0] + 1] - x[1], enumerate(occurrences[:-1]))
print(min(distances))


n = int(input())
a = [int(x) for x in input().split()]
mi = min(a)
last_i = 0
cnt = 0
ans = 10 ** 10
for i in range(n):
	if a[i] == mi:
		if cnt == 0:
			last_i = i
		else:
			if i - last_i < ans:
				ans = i - last_i
			last_i = i
		cnt += 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)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
b = [i for i in range(n) if a[i] == m]
lst = [b[i + 1] - b[i] for i in range(0, len(b) - 1)]
print(min(lst))


n = int(input())
a = list(map(int, input().split()))
b = min(a)
minx = n
qq = []
for i in range(len(a)):
	if b == a[i]:
		qq.append(i)
	if len(qq) > 1:
		if qq[-1] - qq[-2] < minx:
			minx = qq[-1] - qq[-2]
print(minx)


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())
a = list(map(int, input().split()))
m = a[0]
res = n
c = 0
for i in range(1, n):
	if a[i] < m:
		m = a[i]
		c = 0
		res = n
	elif a[i] == m:
		if c < res:
			res = c
		c = 0
	else:
		c += 1
print(res + 1)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
m_dist = float('inf')
dist = 0
l = a.index(m)
for i in range(l + 1, n):
	if a[i] == m:
		dist = i - l
		m_dist = min(m_dist, dist)
		l = i
print(m_dist)


n = int(input())
a = [int(i) for i in input().split()]
m = 1000000000000000
lastm = None
r = 1000000000000000
for i in range(n):
	if a[i] < m:
		m = a[i]
		lastm = i
		r = 1000000000000000
	elif a[i] == m:
		tr = i - lastm
		if tr < r:
			r = tr
		lastm = i
print(r)


num = int(input())
values = [int(x) for x in input().split()]
m = min(values)
l = []
for i in range(num):
	if values[i] == m:
		l.append(i)
d = num
for i in range(len(l) - 1):
	if d > l[i + 1] - l[i]:
		d = l[i + 1] - l[i]
print(d)


n = int(input())
a = list(map(int, input().split()))
l = []
mini = 100000000000
for i in range(n):
	if a[i] < mini:
		mini = a[i]
for i in range(n):
	if mini == a[i]:
		l.append(i)
s = 100000000000
s = 100000000000
for i in range(1, len(l)):
	if s > l[i] - l[i - 1]:
		s = l[i] - l[i - 1]
print(s)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
prev_index = a.index(m)
min_distance_so_far = float('inf')
for i in range(prev_index + 1, len(a)):
	if a[i] == m:
		distance = i - prev_index
		prev_index = i
		min_distance_so_far = min(min_distance_so_far, distance)
print(min_distance_so_far)


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


n = int(input())
a = [int(x) for x in input().split()]
mini = 10 ** 10
for i in range(len(a)):
	if a[i] < mini:
		mini = a[i]
p = []
for i in range(len(a)):
	if a[i] == mini:
		p.append(i)
ans = n + 1
for i in range(1, len(p)):
	if p[i] - p[i - 1] < ans:
		ans = p[i] - p[i - 1]
print(ans)


n = int(input())
arr = list(map(int, input().split()))
minn = min(arr)
index = -1
min_id = 9999999
for i in range(n):
	if arr[i] == minn:
		if index != -1:
			if min_id > abs(i - index):
				min_id = abs(i - index)
		index = i
print(min_id)


R = lambda : list(map(int, input().split()))
n = int(input())
a = R()
m = min(a)
d = []
c = 1000000007
for i in range(n):
	if a[i] == m:
		d.append(i)
for i in range(1, len(d)):
	c = min(c, d[i] - d[i - 1])
print(c)


n = int(input())
b = [int(x) for x in input().split()]
a = []
for i in range(n):
	a.append(b[i])
minm = a[0]
for i in range(n):
	minm = min(minm, a[i])
l = []
for i in range(n):
	if a[i] == minm:
		l.append(i)
l.sort()
x = l[1] - l[0]
for i in range(2, len(l)):
	y = l[i] - l[i - 1]
	if x > y:
		x = y
print(x)


n = int(input())
a = [int(i) for i in input().split()]
m = min(a)
t = a.count(m)
k = []
ind = 0
for i in range(t):
	for j in range(ind, n):
		if a[j] == m:
			k.append(j)
			ind = j + 1
			break
m = max(k)
for i in range(len(k) - 1):
	m = min(m, k[i + 1] - k[i])
print(m)


n = int(input())
a = input()
a = list(map(int, a.split(' ')))
mn = 1000000000.0
ans = 1000000000.0
dp = dict()
for i in range(0, len(a)):
	mn = min(mn, a[i])
for i in range(0, len(a)):
	if a[i] == mn:
		if a[i] in dp:
			ans = min(ans, i - dp[a[i]])
		dp[a[i]] = i
print(ans)


n = int(input())
l = list(map(int, input().split()))
a = min(l)
f = l.index(a)
c = n
for i in range(f + 1, n):
	if l[i] == a:
		m = i - f
		if m < c:
			c = m
		f = i
print(c)


n = int(input())
l = list(map(int, input().split()))
m = min(l)
ans = float('inf')
left = -1
for i in range(n):
	if l[i] == m:
		if left == -1:
			left = i
		else:
			ans = min(ans, i - left)
			left = 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())
a = list(map(int, input().split()))
(q, r) = (min(a), 10 ** 5)
w = a.index(q)
for i in range(w + 1, n):
	if a[i] == q:
		r = min(r, i - w)
		w = i
print(r)


n = int(input())
l = [int(i) for i in input().split()]
mini = min(l)
d = {}
karma = 0
mind = 10 ** 9
for i in range(n):
	if l[i] == mini and karma == 0:
		karma = 1
		d[l[i]] = i
	elif l[i] == mini:
		mind = min(mind, i - d[l[i]])
		d[l[i]] = i
print(mind)


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()))
m = 100000000000000000000000000000
for i in range(n):
	if a[i] < m:
		m = a[i]
l = -100000000000000000000000
z = 1000000000000000000000000000000
for i in range(n):
	if a[i] == m:
		z = min(z, i - l)
		l = i
print(z)


n = int(input())
a = [int(i) for i in input().split()]
m = min(a)
m_l = 1
l = []
f = 0
for i in range(n):
	if f:
		if m == a[i]:
			l.append(m_l)
			m_l = 1
		elif f:
			m_l += 1
	elif m == a[i]:
		f = 1
print(min(l))


n = int(input())
a = list(map(int, input().split()))
b = min(a)
min_val = 1 + 10 ** 9
prev_ind = a.index(b)
for i in range(prev_ind + 1, len(a)):
	if a[i] == b:
		ind = i
		if ind - prev_ind < min_val:
			min_val = ind - prev_ind
		prev_ind = ind
print(min_val)


def solve():
	n = int(input())
	m = [int(s) for s in input().split()]
	r = 0
	m_el = min(m)
	ans = float('inf')
	for i in range(n):
		if r == 0:
			if m[i] == m_el:
				r = 1
		elif m[i] == m_el:
			ans = min(ans, r)
			r = 1
		else:
			r += 1
	print(ans)
solve()


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())
num = list(map(int, input().split()))
mini = min(num)
index = []
for i in range(len(num)):
	if num[i] == mini:
		index.append(i)
minim = index[1] - index[0]
for i in range(1, len(index) - 1):
	diff = index[i + 1] - index[i]
	if minim > diff:
		minim = diff
print(minim)


n = int(input())
a = list(map(int, input().split()))
minv = 1 << 30
minid = None
answer = 1 << 30
for (i, ai) in enumerate(a):
	if ai < minv:
		minv = ai
		answer = 1 << 30
		minid = i
	elif ai == minv:
		if answer > i - minid:
			answer = i - minid
		minid = i
print(answer)


t = int(input())
a = list(map(int, input().split()))
b = min(a)
j = a.index(b)
x = []
for i in range(j + 1, t):
	if a[i] == b:
		x.append(i - j)
		j = i
print(min(x))


noe = int(input())
arr = [int(x) for x in input().split()]
sarr = sorted(arr)
need = -1
for i in range(1, noe):
	if sarr[i] == sarr[i - 1]:
		need = sarr[i]
		break
need = sarr[i]
indices = sorted([i for (i, x) in enumerate(arr) if x == need])
mins = 10000000000.0
for x in range(1, len(indices)):
	mins = min(mins, indices[x] - indices[x - 1])
print(mins)


getInputList = lambda : list(input().split())
getInputIntList = lambda : list(map(int, input().split()))
n = int(input())
arr = getInputIntList()
m = min(arr)
fr = 10 ** 6
range_start = True
indices = [i for (i, x) in enumerate(arr) if x == m]
dis = []
for i in range(1, len(indices)):
	dis.append(indices[i] - indices[i - 1])
print(min(dis))


def solve(arr):
	minPos = 0
	minDist = 999999999
	minVal = arr[0]
	for i in range(1, len(arr)):
		if arr[i] < minVal:
			minVal = arr[i]
			minDist = 999999999
			minPos = i
		elif arr[i] == minVal:
			dist = i - minPos
			if dist < minDist:
				minDist = dist
			minPos = i
	return minDist

def test():
	print(solve([3, 3, 4, 3]) == 1)
	print(solve([5, 6, 5]) == 2)
	print(solve([5, 5, 6, 5, 4, 5, 6, 4]) == 3)
	print(solve([2, 1, 3, 5, 4, 1, 2, 3, 1]) == 3)

def ni():
	s = input()
	while len(s) == 0:
		s = input()
	try:
		return int(s)
	except:
		return 0

def nia():
	s = input()
	while len(s) == 0:
		s = input()
	s = s.split()
	iVal = []
	for i in range(len(s)):
		iVal.append(int(s[i]))
	return iVal
n = ni()
print(solve(nia()))


n = int(input())
l = list(map(int, input().split(' ')))
index_of_minimums = []
TheMin = min(l)
for i in range(n):
	if l[i] == TheMin:
		index_of_minimums.append(i)
dist = [index_of_minimums[i + 1] - index_of_minimums[i] for i in range(len(index_of_minimums) - 1)]
print(min(dist))


am = int(input())
arr = list(map(int, input().split()))
m = min(arr)
ind = []
for i in range(am):
	if arr[i] == m:
		ind.append(i)
minWas = 99999999999
for i in range(1, len(ind)):
	minWas = min(minWas, ind[i] - ind[i - 1])
print(minWas)


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = 1
if debug:
	test_count = inp()
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	n = inp()
	a = inlt()
	m = min(a)
	last = -1
	ans = n
	for i in range(n):
		if a[i] == m:
			if last != -1:
				ans = min(ans, i - last)
			last = i
	print(ans)


import re
import sys
exit = sys.exit
from bisect import bisect_left as bsl, bisect_right as bsr
from collections import Counter, defaultdict as ddict, deque
from functools import lru_cache
cache = lru_cache(None)
from heapq import *
from itertools import *
from math import inf
from pprint import pprint as pp
enum = enumerate
ri = lambda : int(rln())
ris = lambda : list(map(int, rfs()))
rln = sys.stdin.readline
rl = lambda : rln().rstrip('\n')
rfs = lambda : rln().split()
mod = 1000000007
d4 = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d8 = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
n = ri()
a = ris()
ans = mi = i = inf
for (j, x) in enum(a):
	if mi < x:
		continue
	if x < mi:
		mi = x
		ans = inf
	else:
		ans = min(ans, j - i)
	i = j
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
minx = []
ksao = min(a)
for i in range(n):
	if a[i] == ksao:
		minx.append(i)
mins = 10 ** 5 + 1
for i in range(len(minx) - 1):
	mins = min(mins, minx[i + 1] - minx[i])
print(mins)


n = int(input())
l = [int(i) for i in input().split(' ')]
m = min(l)
x = []
for i in range(n):
	if l[i] == m:
		x.append(i)
o = []
for i in range(len(x) - 1):
	o.append(x[i + 1] - x[i])
print(min(o))


n = int(input())
a = list(map(int, input().split()))
min = min(a)
p = -100000
dis = 100000
for i in range(n):
	if a[i] == min:
		if i - p < dis:
			dis = i - p
		p = i
print(dis)


import math
n = int(input())
a = list(map(int, input().strip().split(' ')))
m = min(a)
lst = []
for i in range(n):
	if a[i] == m:
		lst.append(i)
mi = 1000000
for i in range(1, len(lst)):
	if lst[i] - lst[i - 1] < mi:
		mi = lst[i] - lst[i - 1]
print(mi)


from sys import stdin
input = stdin.readline
n = int(input())
list1 = [int(x) for x in input().split()]
small = min(list1)
index = []
count = 0
for i in range(n):
	if list1[i] == small:
		index.append(i)
		count += 1
min_value = 9999999
for i in range(1, count):
	if index[i] - index[i - 1] < min_value:
		min_value = index[i] - index[i - 1]
print(min_value)


import math

def main():
	n = int(input())
	a = list(map(int, input().split()))
	mn = min(a)
	arr = []
	for i in range(n):
		if a[i] == mn:
			arr.append(i + 1)
	ans = 10000000000.0
	for i in range(1, len(arr)):
		ans = min(arr[i] - arr[i - 1], ans)
	print(ans)
	return
main()


n = int(input())
L = list(map(int, input().split(' ')))
res = 10 ** 5
mini = min(L)
cur = 0
while L[cur] != mini:
	cur += 1
a = cur
for i in range(cur + 1, n):
	if L[i] == mini:
		res = min(res, i - a)
		a = i
print(res)


n = int(input())
numbers = input().split(' ')
minimum = None
positions = []
for i in range(n):
	number = int(numbers[i])
	if minimum == number:
		positions.append(i)
	elif minimum is None or number < minimum:
		minimum = number
		positions = [i]
last_pos = positions[0]
min_distance = None
for i in range(1, len(positions)):
	distance = positions[i] - last_pos
	if min_distance is None or distance < min_distance:
		min_distance = distance
	last_pos = positions[i]
print(min_distance)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
last = -1
ans = 10 ** 18
for (i, el) in enumerate(a):
	if el == m:
		if last != -1:
			ans = min(ans, i - last)
		last = i
print(ans)


from sys import stdin, stdout
from math import floor
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def solve():
	n = inp()
	l = li()
	a = min(l)
	x = []
	for i in range(n):
		if l[i] == a:
			x.append(i)
	mi = float('inf')
	for i in range(1, len(x)):
		mi = min(mi, x[i] - x[i - 1])
	pr(mi)
for _ in range(1):
	solve()


input()
a = list(map(int, input().split()))
x = min(a)
r = 10 ** 9
ans = 10 ** 9
go = False
for i in a:
	if i == x:
		ans = min(ans, r)
		r = 0
		go = True
	r += int(go)
print(ans)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
md = 100000
l = [i for (i, x) in enumerate(a) if x == m]
for j in range(1, len(l)):
	if md > l[j] - l[j - 1]:
		md = l[j] - l[j - 1]
print(md)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
l = []
com = 1
for i in range(a.index(m) + 1, n):
	if a[i] > m:
		com += 1
	else:
		l.append(com)
		com = 1
print(min(l))


a = int(input())
b = list(map(int, input().split()))
c = set()
d = []
e = min(b)
x = 0
for i in range(len(b)):
	if b[i] == e:
		d.append(i)
x = [d[i + 1] - d[i] for i in range(len(d) - 1)]
print(min(x))


n = int(input())
r = lambda : list(map(int, input().split()))
arr = r()
m = min(arr)
ans = [x for (x, i) in enumerate(arr) if i == m]
z = float('inf')
for i in range(len(ans) - 1):
	z = min(z, ans[i + 1] - ans[i])
print(z)


n = int(input())
l = list(map(int, input().split()))
a = min(l)
p = l.count(a)
for i in range(n):
	if p >= 2:
		break
	else:
		l.remove(a)
		a = min(l)
c = 0
x = []
for i in l:
	if i == a and c == 0:
		c += 1
	elif c >= 1 and i != a:
		c += 1
	elif i == a and c >= 1:
		x.append(c)
		c = 1
print(min(x))


n = int(input())
a = list(map(int, input().split()))
mini = 1000000001
d = {}
for i in range(n):
	if a[i] < mini:
		mini = a[i]
		d[mini] = [i]
	elif a[i] == mini:
		d[mini].append(i)
ans = 100001
for i in range(1, len(d[mini])):
	if d[mini][i] - d[mini][i - 1] < ans:
		ans = d[mini][i] - d[mini][i - 1]
print(ans)


nsdg = int(input())
sgg = list(map(int, input().split()))
s = min(sgg)
gog = 0
for i in range(nsdg):
	if sgg[i] == s:
		gog = i
		break
answer = 10 ** 10
for i in range(gog + 1, nsdg):
	if sgg[i] == s:
		answer = min(answer, i - gog)
		gog = i
print(answer)


n = int(input())
A = list(map(int, input().split()))
mi = min(A)
rec = float('inf')
pre_index = -1
for i in range(len(A)):
	if A[i] == mi:
		if pre_index != -1:
			rec = min(i - pre_index, rec)
			pre_index = i
		else:
			pre_index = i
print(rec)


l = int(input())
s = [int(x) for x in input().split(' ')]
m = min(s)
ind = []
for i in range(l):
	if s[i] == m:
		ind.append(i)
dif = [ind[i] - ind[i - 1] for i in range(1, len(ind))]
print(min(dif))


n = int(input())
a = [int(x) for x in input().split()]
m = 10 ** 10
for x in a:
	if m > x:
		m = x
ind = []
for x in range(n):
	if a[x] == m:
		ind.append(x)
min1 = 10 ** 10
for x in range(len(ind) - 1):
	if ind[x + 1] - ind[x] < min1:
		min1 = ind[x + 1] - ind[x]
print(min1)


n = int(input())
arr = [int(x) for x in input().split()]
arr_min = min(arr)
min_pos = 0
min_r = set()
for i in range(0, n):
	if arr[i] == arr_min:
		min_pos = i
		break
for i in range(min_pos + 1, n):
	if arr[i] == arr_min:
		min_r.add(i - min_pos)
		min_pos = i
print(min(min_r))


n = int(input())
a = list(map(int, input().split()))
mi = min(a)
d = []
d1 = []
c = 0
for i in range(len(a)):
	if a[i] == mi:
		d.append(i)
		if len(d) > 1:
			d1.append(d[-1] - d[-2])
print(min(d1))


x = int(input())
a = list(map(int, input().split()))
y = min(a)
f = 9999999999
s = -111111
for i in range(len(a)):
	if a[i] == y:
		f = min(f, i - s)
		s = i
print(f)


a = int(input())
t = []
s = list(map(int, input().split()))
z = min(s)
b = s.index(z)
for k in range(b + 1, a):
	if s[k] == z:
		t.append(k - b)
		b = k
print(min(t))


def mp():
	return map(int, input().split())

def it():
	return int(input())
n = it()
l = list(mp())
m = min(l)
flag = 0
ans = 0
c = 0
k = float('inf')
for i in range(len(l)):
	if l[i] == m:
		c += 1
		flag = 1
		if ans > 0:
			k = min(k, ans)
			ans = 0
	elif flag == 1:
		ans += 1
		if c < 2:
			c = 0
		else:
			pass
if c < 2:
	print(k + 1)
else:
	print(1)


from sys import stdin
n = int(stdin.readline())
a = [int(o) for o in stdin.readline().split()]
mn = min(a)
last = -1
ans = 10 ** 9
for (i, val) in enumerate(a):
	if val == mn:
		if last != -1:
			ans = min(ans, i - last)
		last = i
print(ans)


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


n = int(input())
arr = list(map(int, input().split()))
ans = []
c = min(arr)
[ans.append(i) for i in range(len(arr)) if arr[i] == c]
diff = len(arr)
for i in range(1, len(ans)):
	if ans[i] - ans[i - 1] < diff:
		diff = ans[i] - ans[i - 1]
print(diff)


import sys
num = int(input())
x = list(map(int, input().strip().split(' ')))
minelement = min(x)
minoutput = 0
index = []
for i in range(len(x)):
	if x[i] == minelement:
		index.append(i)
for i in range(len(index) - 1):
	tmp = index[i + 1] - index[i]
	if minoutput == 0:
		minoutput = tmp
	if tmp < minoutput:
		minoutput = tmp
print(minoutput)


def getinput():
	return [int(x) for x in input().strip().split()]
n = int(input())
arr = getinput()
val = min(arr)
ind = []
for i in range(n):
	if arr[i] == val:
		ind.append(i)
ans = n + 1
for i in range(1, len(ind)):
	ans = min(ans, ind[i] - ind[i - 1])
print(ans)


n = int(input())
a = list(map(int, input().split()))
mini = min(a)
minpos = []
for i in range(n):
	if a[i] == mini:
		minpos.append(i)
ans = 10000000000
for i in range(len(minpos) - 1):
	ans = min(ans, minpos[i + 1] - minpos[i])
print(ans)


n = int(input())
c = list(map(int, input().split(' ')))
mi = min(c)
(l, r) = (-1, 0)
res = float('inf')
for i in range(len(c)):
	if c[i] == mi:
		if l != -1:
			res = min(res, i - l)
			l = i
		else:
			l = i
print(res)


n = int(input())
l = list(map(int, input().split()))
m = min(l)
a = []
k = []
for i in range(len(l)):
	if l[i] == m:
		a.append(i)
for j in range(len(a) - 1):
	s = a[j + 1] - a[j]
	k.append(s)
print(min(k))


n = int(input())
a = [int(k) for k in input().split()]
mi = min(a)
min_dist = 10 ** 10
index = []
for i in range(len(a)):
	if a[i] == mi:
		index.append(i)
for i in range(len(index) - 1):
	if index[i + 1] - index[i] < min_dist:
		min_dist = index[i + 1] - index[i]
print(min_dist)


n = int(input())
l = list(map(int, input().split()))
m = min(l)
mi = l.index(m)
ln = []
for i in range(mi + 1, n):
	if l[i] == m:
		ln.append(i - mi)
		mi = i
print(min(ln))


n = int(input())
A = [int(x) for x in input().split()]
m = min(A)
A = [i for (i, x) in enumerate(A) if x == m]
print(min([A[i + 1] - A[i] for i in range(len(A) - 1)]))


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)


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


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 15
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = LI()
	d = collections.defaultdict(lambda : -inf)
	m = inf
	t = min(a)
	for i in range(n):
		c = a[i]
		if c != t:
			continue
		if i - d[c] < m:
			m = i - d[c]
		d[c] = i
	return m
print(main())


input()
arr = [int(x) for x in input().split()]
minval = min(arr)
(minarr, i) = ([], 0)
while True:
	try:
		mi = arr.index(minval, i)
	except ValueError:
		break
	minarr.append(mi)
	i = mi + 1
print(min((abs(x - y) for (x, y) in zip(minarr, minarr[1:]))))


def mindist(l):
	f = 'ndone'
	if max(l) == min(l):
		return 1
	smallest = max(l) - min(l)
	for i in range(1, len(l)):
		if l[i] - l[i - 1] == 1:
			f = 'done'
			return 1
		elif l[i] - l[i - 1] < smallest:
			smallest = l[i] - l[i - 1]
	if f == 'ndone':
		return smallest
n = int(input())
a = list(map(int, input().split()))
minimum = min(a)
pos = []
for i in range(len(a)):
	if a[i] == minimum:
		pos.append(i)
print(mindist(pos))


n = int(input())
a = [int(i) for i in input().split()]
m = min(a)
b = []
otvet = []
pos0 = a.index(m)
for i in range(len(a)):
	if (a[i] == m) & (i != pos0):
		b.append(i)
for i in b:
	otvet.append(i - pos0)
	pos0 = i
print(min(otvet))


n = int(input())
a = [int(i) for i in input().split()]
mx = min(a)
a = [i for i in range(n) if a[i] == mx]
d = [a[i] - a[i - 1] for i in range(1, len(a))]
print(min(d))


n = int(input())
nums = list(map(int, input().split(' ')))

def main():
	m = min(nums)
	l = -n - 1
	ans = n + 1
	for (i, e) in enumerate(nums):
		if e == m:
			if i - l < ans:
				ans = i - l
			l = i
	print(ans)
main()


n = int(input())
lst = list(map(int, input().split()))
mn = min(lst)
i1 = 0
i2 = 0
flag = True
answer = float('inf')
for i in range(n):
	if flag and lst[i] == mn:
		i1 = i
		k = 0
		flag = False
	elif lst[i] == mn and k % 2 == 0:
		i2 = i
		k += 1
		if i2 - i1 < answer:
			answer = i2 - i1
	elif lst[i] == mn and k % 2 == 1:
		i1 = i
		k += 1
		if i1 - i2 < answer:
			answer = i1 - i2
print(answer)


n = int(input())
a = list(map(int, input().split()))
ans = 10 ** 10
(prev, t) = (-1, min(a))
for i in range(n):
	if a[i] == t:
		if prev != -1:
			ans = min(ans, i - prev)
		prev = i
print(ans)


n = int(input())
arr = [int(x) for x in input().split()]
ar = sorted(arr)
m1 = ar[0]
m2 = ar[1]
arr1 = [int(10000000000.0)] * n
ind = -1
for i in range(n):
	if arr[i] == m2 and ind != -1:
		arr1[i] = i - ind
	if arr[i] == m1:
		ind = i
ind = -1
for i in range(n - 1, -1, -1):
	if arr[i] == m2 and ind != -1:
		arr1[i] = min(ind - i, arr1[i])
	if arr[i] == m1:
		ind = i
arr1 = sorted(arr1)
print(arr1[0])


n = int(input())
c = list(map(int, input().split()))
m = min(c)
l = -1
x = n
for i in range(n):
	if c[i] == m:
		if l != -1:
			x = min(x, i - l)
		l = i
print(x)


n = int(input())
a = list(map(int, input().split()))
j = min(a)
s = []
for i in range(0, len(a)):
	if a[i] == j:
		s.append(i)
mina = None
for i in range(0, len(s) - 1):
	if mina == None:
		mina = s[i + 1] - s[i]
	elif s[i + 1] - s[i] < mina:
		mina = s[i + 1] - s[i]
print(mina)


n = int(input())
arr = list(map(int, input().split()))
smallest = min(arr)
prev = -1
currMin = 10 ** 5
for i in range(n):
	if prev == -1 and arr[i] == smallest:
		prev = i
	elif arr[i] == smallest:
		if i - prev < currMin:
			currMin = i - prev
		prev = i
print(currMin)


n = int(input())
arr = list(map(int, input().split()))
mini = 1000000000 + 1
pos = -1
for i in range(n):
	if arr[i] < mini:
		mini = arr[i]
		pos = i
len = n - 1
for i in range(pos + 1, n):
	if arr[i] == mini:
		len = min(len, i - pos)
		pos = i
print(len)


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


n = int(input())
a = [int(x) for x in input().split()]
m = min(a)
f = True
best = n
cur = 0
for i in range(n):
	if a[i] == m and f:
		f = False
		cur = i
	elif a[i] == m and (not f):
		best = min(best, i - cur)
		cur = i
print(best)


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


n = int(input())
arr = list(map(int, input().split()))
minn = min(arr)
ans = []
for i in range(n):
	if arr[i] == minn:
		ans.append(i)
m = 10 ** 100
for i in range(len(ans) - 1):
	if ans[i + 1] - ans[i] < m:
		m = ans[i + 1] - ans[i]
print(m)


k = input()
m = [int(i) for i in input().split()]
minN = min(m)
i = 0
masRes = []
counter = 0
for i in range(m.index(minN) + 1, len(m)):
	counter += 1
	if m[i] == minN:
		masRes.append(counter)
		counter = 0
print(min(masRes))


import sys
n = int(input())
nums = [int(x) for x in input().split()]
minv = min(nums)
minx = []
for i in range(len(nums)):
	if nums[i] == minv:
		minx.append(i)
ans = 1000000
for i in range(1, len(minx)):
	ans = minx[i] - minx[i - 1] if minx[i] - minx[i - 1] < ans else ans
print(ans)


n = input()
arr = [int(i) for i in input().split()]
min = 10 ** 9 + 1
for i in arr:
	if i < min:
		min = i
indices = [i for (i, x) in enumerate(arr) if x == min]
d = len(arr) + 1
for i in range(len(indices) - 1):
	temp = indices[i + 1] - indices[i]
	if temp < d:
		d = temp
print(d)


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 = list(map(int, input().split()))
p = min(a)
for u in range(len(a)):
	if a[u] == p:
		break
j = u
l = []
for i in range(j + 1, len(a)):
	if a[i] == p:
		l.append(i - j)
		j = i
print(min(l))


n = int(input())
arr = list(map(int, input().split()))
m = min(arr)
ans = 1000000
for i in range(len(arr)):
	if arr[i] == m:
		t = i
		break
for i in range(t + 1, len(arr)):
	if m == arr[i]:
		k = i
		ans = min(ans, abs(k - t))
		t = k
print(ans)


a = int(input())
lis = list(map(int, input().split()))
x = min(lis)
rs = []
r = 1
count = False
for i in lis:
	if not count:
		if i == x:
			count = True
	elif i == x:
		rs.append(r)
		r = 1
	else:
		r += 1
print(min(rs))


n = int(input())
a = list(map(int, input().split()))
m = min(a)
ind = []
for i in range(n):
	if a[i] == m:
		ind += [i]
ans = ind[1] - ind[0]
for i in range(2, len(ind)):
	ans = min(ans, ind[i] - ind[i - 1])
print(ans)


(z, zz, dgraphs, mod) = (input, lambda : list(map(int, z().split())), {}, 10 ** 9 + 7)
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
l = zz()
t = min(l)
lx = []
j = 1
for i in l:
	if i == t:
		lx.append(j)
	j += 1
lx = sorted(lx)
ans = 3489777777777777777
x = lx[0]
for i in lx[1:]:
	t = i - x
	if t <= ans:
		ans = t
	x = i
print(ans)


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


n = int(input())
a = [int(s) for s in input().split()]
m = None
mi = None
mm = None
for (i, v) in enumerate(a):
	if not m or v < m:
		m = v
		mi = i
		mm = None
	elif v == m:
		if not mm or i - mi < mm:
			mm = i - mi
		mi = i
print(mm)


import math
n = int(input())
X = input()
x = X.split()
arr = []
m = math.inf
for i in x:
	i = int(i)
	if i < m:
		m = i
for i in range(len(x)):
	if int(x[i]) == int(m):
		arr.append(i)
temp = arr[1] - arr[0]
for i in range(len(arr) - 1):
	if arr[i + 1] - arr[i] < temp:
		temp = arr[i + 1] - arr[i]
print(temp)


n = int(input())
arr = list(map(int, input().split()))
d = dict()
mn = min(arr)
prev = None
ans = float('inf')
for i in range(n):
	if arr[i] == mn:
		if not prev:
			prev = i + 1
		else:
			ans = min(ans, i - prev + 1)
			prev = i + 1
if ans != float('inf'):
	print(ans)
else:
	print(1)


n = int(input())
l = list(map(int, input().split()))
r = min(l)
index = []
min1 = float('inf')
for i in range(len(l)):
	if r == l[i]:
		index.append(i)
for i in range(1, len(index)):
	min1 = min(min1, abs(index[i] - index[i - 1]))
print(min1)


n = int(input())
A = list(map(int, input().split()))
a = min(A)
ans = []
for i in range(n):
	if A[i] == a:
		ans.append(i + 1)
ans1 = int(10000000000.0)
for i in range(1, len(ans)):
	ans1 = min(ans1, ans[i] - ans[i - 1])
print(ans1)


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)


from sys import stdin, stdout
from os import path
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
	stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

	def S():
		return stdin.readline().rstrip()

	def Sn():
		return stdin.readline().split(' ')

def Out(whatever):
	return stdout.write(whatever)
n = I()
arr = list(In())
m = min(arr)
aux = [i for i in range(n) if arr[i] == m]
k = len(aux)
Out(str(min([aux[i + 1] - aux[i] for i in range(k - 1)])))


n = int(input())
array = [i for i in map(int, input().split())]
min_num = array[0]
d = dict()
for i in range(n):
	num = array[i]
	if num not in d:
		d[num] = []
		d[num].append(i)
	else:
		d[num].append(i)
for key in d.keys():
	if key < min_num and len(d[key]) >= 2:
		min_num = key
pos_min = d[min_num]
result = pos_min[1] - pos_min[0]
for i in range(len(pos_min) - 1):
	result = min(result, pos_min[i + 1] - pos_min[i])
print(result)


n = int(input())
l = list(map(int, input().split()))
m = min(l)
ind = [i for (i, x) in enumerate(l) if x == m]
print(min((ind[x + 1] - ind[x] for x in range(len(ind) - 1))))


n = int(input())
a = list(map(int, input().split()))
minimum = a.index(min(a))
last = 0
l = []
for i in range(len(a)):
	if a[i] == a[minimum]:
		l.append(i - last)
		last = i
l = l[1:]
print(min(l))


n = int(input())
a = list(map(int, input().split()))
(t, p, ans) = (min(a), -n, n)
for i in range(n):
	if a[i] != t:
		continue
	ans = min(ans, i - p)
	p = i
print(ans)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
index = -1
dist = 0
minDist = 99999999
for i in range(n):
	if a[i] == m:
		if index != -1:
			dist = i - index
			if dist < minDist:
				minDist = dist
		index = i
print(minDist)


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))


def h(n, a):
	v = min(a)
	minx = n
	w = []
	for i in range(0, n):
		if a[i] == v:
			w.append(i)
			if len(w) >= 2:
				x = w[-1]
				y = w[-2]
				if x - y < minx:
					minx = x - y
	return minx
n = input().strip()
a = input().strip().split()
a = list(map(int, a))
print(h(int(n), a))


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)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
index = -1
dist = 0
distances = []
for i in range(n):
	if a[i] == m:
		if index != -1:
			dist = i - index
			distances.append(dist)
		index = i
print(min(distances))


N = int(input())
a = []
a = list(map(int, input().strip().split()))
m = min(a)
ml = N
isFirst = True
(first, sec) = (0, 0)
for i in range(N):
	if m == a[i]:
		if isFirst:
			first = i
			sec = i
			isFirst = False
		else:
			first = sec
			sec = i
			ml = min(ml, sec - first)
print(ml)


n = int(input())
num_list = list(map(int, input().split()))
num_min = min(num_list)
ind_min = [i for i in range(n) if num_list[i] == num_min]
ans = [ind_min[i + 1] - ind_min[i] for i in range(len(ind_min) - 1)]
print(min(ans))


N = int(input())
A = list(map(int, input().split()))

def solve():
	m = min(A)
	pre = -1
	d = float('inf')
	for (i, a) in enumerate(A):
		if a == m:
			if pre != -1:
				d = min(d, i - pre)
			pre = i
	print(d)
solve()


n = int(input())
a = list(map(int, input().split()))
m = min(a)
ans = 100000000
x = -1
for i in range(n):
	if a[i] == m:
		if x == -1:
			x = i + 0
		else:
			if i - x < ans:
				ans = i - x
			x = i + 0
print(ans)


n = int(input())
l = list(map(int, input().split()))
m = min(l)
x = []
k = 10 ** 10
for i in range(n):
	if l[i] == m:
		x.append(i)
for i in range(1, len(x)):
	s = x[i] - x[i - 1]
	if s < k:
		k = s
print(k)


n = input()
arr = [int(x) for x in input().split()]
min_n = min(arr)
last_idx = None
best_diff = None
for (idx, val) in enumerate(arr):
	if val == min_n:
		if last_idx is None:
			pass
		elif best_diff is None:
			best_diff = idx - last_idx
		elif best_diff > idx - last_idx:
			best_diff = idx - last_idx
		last_idx = idx
print(best_diff)


n1 = int(input())
n = [int(i) for i in input().split()]
min1 = 10000000001
minl = 10000000001
for i in range(len(n)):
	if n[i] < min1:
		min1 = n[i]
		l1 = i
for i in range(l1 + 1, len(n)):
	if n[i] == min1:
		if i - l1 < minl:
			minl = i - l1
		l1 = i
print(minl)


n = int(input())
a = [int(s) for s in input().split()]
k = min(a)
b = []
answer = 1000000000000000000000
for i in range(n):
	if a[i] == k:
		b.append(i)
for i in range(len(b) - 1, 0, -1):
	if b[i] - b[i - 1] < answer:
		answer = b[i] - b[i - 1]
print(answer)


n = int(input())
s = input().split()
a = []
limit = 10 ** 9 + 1
m = limit
for i in range(n):
	t = int(s[i])
	m = min(m, t)
	a.append(t)
first = -1
second = -1
ans = limit
for i in range(n):
	if a[i] == m:
		if first == -1:
			first = i
		else:
			second = i
			ans = min(ans, second - first)
			first = second
			second = -1
print(ans)


import sys
n = int(input())
nums = [x for x in map(int, input().split())]
mini = min(nums)
dists = []
miniDistance = 10 ** 9 + 1
for i in range(n):
	if nums[i] == mini:
		dists.append(i)
for i in range(1, len(dists)):
	miniDistance = min(dists[i] - dists[i - 1], miniDistance)
print(miniDistance)


n = int(input())
a = list(map(int, input().split(' ')))
mn = 10 ** 9 + 1
Lmn = n + 1
L = 0
for i in a:
	if mn < i:
		L += 1
		continue
	if mn == i:
		L += 1
		if L < Lmn:
			Lmn = L
		L = 0
		continue
	if mn > i:
		mn = i
		Lmn = n + 1
		L = 0
print(Lmn)


n = int(input())
arr = [int(i) for i in input().split(' ')]
minimum = min(arr)
counter = -1
nearest = 10 ** 5
for i in range(n):
	if arr[i] == minimum:
		if counter == -1:
			counter = 0
		else:
			if counter + 1 < nearest:
				nearest = counter + 1
			counter = 0
	elif counter == -1:
		continue
	else:
		counter += 1
print(nearest)


from collections import defaultdict as dfd
n = int(input().strip())
dic = dfd(list)
arr = [int(i) for i in input().strip().split(' ')]
for i in range(len(arr)):
	dic[arr[i]].append(i)
ar = dic[min(arr)]
mi = 10 ** 10
for i in range(len(ar) - 1):
	mi = min(mi, ar[i + 1] - ar[i])
print(mi)


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)


l = int(input())
a = list(map(int, input().split()))
m = min(a)
count = []
i = 0
while i < l:
	if a[i] == m:
		i += 1
		c = 1
		while i < l:
			if a[i] == m:
				count.append(c)
				break
			else:
				c += 1
				i += 1
	else:
		i += 1
print(min(count))


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


from cmath import inf
n = int(input())
a = list(map(int, input().split()))
m = min(a)
last = -1
ans = inf
for (i, el) in enumerate(a):
	if el == m:
		if last != -1:
			ans = min(ans, i - last)
		last = i
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
mi = a[0]
for i in range(n):
	mi = min(mi, a[i])
pre = -1
ans = n
for i in range(n):
	if mi == a[i]:
		if pre != -1:
			ans = min(ans, i - pre)
		pre = i
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
a0 = min(a)
b = []
for i in range(n):
	if a[i] == a0:
		b.append(i)
c = []
if len(b) == 2:
	print(b[1] - b[0])
else:
	for j in range(len(b) - 1):
		a2 = b[j + 1] - b[j]
		c.append(a2)
	print(min(c))


n = int(input())
a = [int(i) for i in input().split()]
minA = min(a)
index = []
for i in range(n):
	if a[i] == minA:
		index.append(i)
index.sort()
lnI = len(index)
minD = 1000000007
for i in range(lnI - 1):
	if index[i + 1] - index[i] < minD:
		minD = index[i + 1] - index[i]
print(minD)


n = int(input())
arr = [int(x) for x in input().split()]
mini = min(arr)
a = []
for (i, j) in enumerate(arr):
	if j == mini:
		a.append(i)
temp = a[1] - a[0]
for i in range(2, len(a)):
	if a[i] - a[i - 1] < temp:
		temp = a[i] - a[i - 1]
print(temp)


n = map(int, input())
from collections import defaultdict
m = defaultdict(list)
arr = map(int, input().split(' '))
_min = None
i = 0
for elem in arr:
	if _min == None:
		_min = elem
	_min = min(_min, elem)
	m[elem].append(i)
	i += 1
positions = m[_min]
l = sorted(positions)
minDiff = l[1] - l[0]
for i in range(2, len(l)):
	minDiff = min(minDiff, l[i] - l[i - 1])
print(minDiff)


n = int(input())
a = [int(x) for x in input().split()]
b = []
x = min(a)
for i in range(n):
	if a[i] == x:
		b.append(i)
prev = b[0]
ans = n
for i in range(1, len(b)):
	if b[i] - prev < ans:
		ans = b[i] - prev
	prev = b[i]
print(ans)


t = input()
n = int(t)
v = list(map(int, input().split()))
ans = 1000000000.0 + 8
for i in range(n):
	ans = min(ans, v[i])
an = 1000000000.0 + 7
pre = -1
for i in range(n):
	if v[i] == ans:
		if pre == -1:
			pre = i
		else:
			an = min(an, i - pre)
			pre = i
print(an)


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


def main():
	n = int(input())
	a = list(map(int, input().split()))
	c = []
	min_number = min(a)
	min_index = n
	for i in range(n):
		if a[i] == min_number:
			c.append(i)
	for i in range(1, len(c)):
		min_index = min(c[i] - c[i - 1], min_index)
	print(min_index)
main()


n = int(input())
ara = input().split()
ara = [int(i) for i in ara]
mn = min(ara)
lst = [i for i in range(n) if ara[i] == mn]
ans = 10000000000000000000
for i in range(len(lst) - 1):
	ans = min(ans, abs(lst[i] - lst[i + 1]))
print(ans)


def getNext(index):
	for a in range(index + 1, len(arr)):
		if arr[a] == minimum:
			return a
	return -1
N = int(input())
arr = list(map(int, input().split()))
minimum = min(arr)
start = arr.index(minimum)
best = float('inf')
nextIndex = getNext(start)
while nextIndex != -1:
	best = min(best, nextIndex - start)
	(start, nextIndex) = (nextIndex, getNext(nextIndex))
print(best)


n = int(input())
arr = [int(i) for i in input().split()]
minm = min(arr)
ans = 1000000000.0
for i in range(len(arr)):
	if arr[i] == minm:
		for j in range(i + 1, len(arr)):
			if arr[j] == minm:
				ans = min(ans, j - i)
				break
print(ans)


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())
a = list(map(int, input().split()))
(s, k, b, d, f) = (min(a), 0, [], 0, 0)
for i in range(len(a)):
	if f == 1:
		d = d + 1
	if f == 1 and a[i] == s:
		f = 0
		b.append(d)
		d = 0
	if a[i] == s:
		f = 1
print(min(b))


n = int(input())
a = list(map(int, input().split()))
k = 100000000000
ans = len(a) + 2
m = min(a)
for i in a[:]:
	if i != m:
		k += 1
	else:
		ans = min(k, ans)
		k = 1
print(ans)


n = int(input())
x = list(map(int, input().split()))
a = []
min_dif = 10 ** 6
x_min = min(x)
for i in range(n):
	if x[i] == x_min:
		a.append(i)
for j in range(1, len(a)):
	if a[j] - a[j - 1] < min_dif:
		min_dif = a[j] - a[j - 1]
print(min_dif)


n = int(input())
a = list(map(int, input().split()))
mini = 10 ** 10
minDistance = n - 1
for i in range(n):
	if a[i] < mini:
		mini = a[i]
		pos = i
		minDistance = n - 1
	elif a[i] == mini:
		minDistance = min(minDistance, i - pos)
		pos = i
print(minDistance)


INF = 10 ** 9
(n, a) = (int(input()), list(map(int, input().split())))
mn = min(a)
(last, dist) = (-INF, INF)
for (idx, elem) in enumerate(a):
	if elem == mn:
		dist = min(dist, idx - last)
		last = idx
print(dist)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
c = a.index(m)
res = float('inf')
for i in range(c + 1, n):
	if a[i] == m:
		res = min(res, i - c)
		c = i
print(res)


n = int(input())
k = input().split()
l = list(map(int, k))
mi = min(l)
rasst = n
x = l.index(mi)
for i in range(x + 1, len(l)):
	if l[i] == mi:
		rasst = min(rasst, i - x)
		x = i
print(rasst)


n = int(input())
A = [int(a) for a in input().split()]
m = min(A)
d = 100001
checkpoint = -1
for i in range(n):
	if A[i] == m:
		if checkpoint > -1:
			aux = i - checkpoint
			d = min(d, aux)
		checkpoint = i
print(d)


t = int(input())
a = [int(i) for i in input().split()]
l = min(a)
x = []
for i in range(len(a)):
	if a[i] == l:
		x.append(i)
mi = []
for i in range(len(x) - 1):
	mi.append(abs(x[i] - x[i + 1]))
print(min(mi))


input()
A = list(map(int, input().split()))
x = min(A)
ind = []
for (i, a) in enumerate(A):
	if a == x:
		ind += [i]
ans = ind[1] - ind[0]
for i in range(2, len(ind)):
	ans = min(ans, ind[i] - ind[i - 1])
print(ans)


n = int(input().rstrip())
array = list((int(t) for t in input().rstrip().split(' ')))
mini = min(array)
min_old_position = 0
min_new_position = 0
min_distance = len(array)
start = True
for i in range(len(array)):
	if array[i] == mini:
		if start:
			start = False
			min_old_position = i
			continue
		else:
			min_new_position = i
			if abs(min_new_position - min_old_position) < min_distance:
				min_distance = abs(min_new_position - min_old_position)
			min_old_position = min_new_position
print(min_distance)


n = int(input())
arr = list(map(int, input().split()))
pos = 0
ans = 10 ** 5 + 1
cur = arr[0]
for i in range(1, n):
	if arr[i] < cur:
		cur = arr[i]
		pos = i
		ans = 10 ** 5 + 1
	elif arr[i] == cur:
		ans = min(ans, i - pos)
		pos = i
print(ans)


import sys, math, queue, bisect
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
n = int(input())
a = list(map(int, input().split()))
mn = min(a)
x = []
for i in range(n):
	if a[i] == mn:
		x.append(i)
print(min([x[i] - x[i - 1] for i in range(1, len(x))]))


n = int(input())
a = list(map(int, input().split()))
k = min(a)
d = max(a) + 1
p = -100000
pas = []
while k in a:
	s = a.index(k)
	a[s] = d
	if s - p == 1:
		exit(print(1))
	pas.append(s - p)
	p = s
print(min(pas))


n = int(input())
A = list(map(int, input().split()))
min_ = min(A)
prev_i = -1
min_i = 10 ** 9 + 1
for (i, a) in enumerate(A):
	if a == min_:
		if prev_i == -1:
			prev_i = i
		else:
			if i - prev_i < min_i:
				min_i = i - prev_i
			prev_i = i
print(min_i)


n = int(input())
l = input().split()
lind = []
min_l = int(l[0])
min_ind = n
for i in range(n):
	l[i] = int(l[i])
	if l[i] < min_l:
		min_l = l[i]
for i in range(n):
	if l[i] == min_l:
		lind.append(i)
for i in range(1, len(lind)):
	if lind[i] - lind[i - 1] < min_ind:
		min_ind = lind[i] - lind[i - 1]
print(min_ind)