<jupyter_start><jupyter_text>https://www.hackerrank.com/challenges/minimum-distances/problem<jupyter_code>#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the minimumDistances function below.
def minimumDistances(a):
    _min = len(a)
    if len(a)==len(set(a)):
        return -1
    for i in range(len(a)):
        for j in range(len(a)):
            if a[i]==a[j] and i!=j:
                _min = min(_min, abs(i-j))              
    return _min
    

if __name__ == '__main__':
    
    n = int(input())

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

    result = minimumDistances(a)
    
    print (result)<jupyter_output>6
 7 1 3 4 1 7
{'fraction_non_alphanumeric': 0.1378299120234604, 'fraction_numerical': 0.013196480938416423, 'mean_word_length': 2.5572916666666665, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '603288', 'license': 'MIT', 'n_tokens_mistral': 262, 'n_tokens_neox': 246, 'n_words': 59, 'path': 'Minimum Distances.ipynb', 'repo_name': 'ayushsubedi/problem_solving', 'size': '682'}