#include <bits/stdc++.h>
using namespace std;
int n;
int a[101010];
int main() {
  int mi;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    mi = (i == 0) ? a[i] : min(mi, a[i]);
  }
  int last = -1, ans = n + 1;
  for (int i = 0; i < n; i++) {
    if (a[i] != mi) continue;
    if (last >= 0) ans = min(ans, i - last);
    last = i;
  }
  printf("%d\n", ans);
  return 0;
}
