#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000005], b[1000005];
int mi = 1000000000;
int c;
int cnt;
int ans = 100000000;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < mi) mi = a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == mi) b[++cnt] = i;
  }
  for (int i = 1; i < cnt; i++) {
    c = b[i + 1] - b[i];
    if (c < ans) ans = c;
  }
  printf("%d", ans);
  return 0;
}
