You are given an array of n integer numbers a0, a1, ..., an - 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 ≤ 105) — size of the given array. The second line contains n integers a0, a1, ..., an - 1 (1 ≤ ai ≤ 109) — 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
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
 /*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
 
/**
 *
 * @author - aman_robotics(Aman Kumar Singh)
 * @Institution - Kalyani Government Engineering College
 */
public class supw
{
    public static void main(String [] args)throws IOException
    {
        FastReader in=new FastReader(System.in);
        int n=in.nextInt();
        long arr[]=new long[n];
        long a[]=new long[n];
        for(int i=0;i<n;i++){
            arr[i]=in.nextLong();
            a[i]=arr[i];
        }
        Arrays.sort(arr);
        long x=arr[0];
        long y=arr[1];
        if(x!=y){
            long b[]=new long[n];
            long c[]=new long[n];
            int p=0;
            int q=0;
            for(int i=0;i<n;i++){
                if(a[i]==x)
                    b[p++]=i;
            }
            for(int i=0;i<n;i++){
                if(a[i]==y)
                    c[q++]=i;
            }
            long z=Integer.MAX_VALUE;
            for(int i=0;i<p;i++){
                for(int j=0;j<q;j++){
                    if(Math.abs(b[i]-b[j])<z)
                        z=Math.abs(b[i]-b[j]);
                }
            }
            System.out.println(z);
        }
        else{
            long d[]=new long[n];
            int r=0;
            for(int i=0;i<n;i++){
                if(a[i]==x)
                    d[r++]=i;
            }
            long e=Math.abs(d[1]-d[0]);
            for(int i=1;i<r-1;i++){
                if(d[i+1]-d[i]<e)
                    e=Math.abs(d[i+1]-d[i]);
            }
            System.out.println(e);
        }
    }
    static class FastReader{
 
        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;
 
        FastReader(InputStream is) {
            in = is;
        }
 
        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }
 
        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan());
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }
 
        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
 
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}