#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  long long int a[n], te = 100000000000, dis, count = 0, p = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (te > a[i]) te = a[i];
  }
  dis = n + 1;
  for (i = 0; i < n; i++) {
    if (te == a[i]) {
      p++;
      if (dis > count && p > 1) {
        dis = count;
      }
      count = 0;
    } else
      count++;
  }
  cout << dis + 1 << endl;
  return 0;
}
