'''

a = collections.Counter(nums).most_common()

n, degree = a[0][0], a[0][1]

if degree == 1:

return 1

ns = [t[0] for t in a if t[1] == degree]

res = len(nums)

for s in ns:

tmp = [i for i, x in enumerate(nums) if x == s]

res = min(res, tmp[-1]-tmp[0]+1)

return res

'''