#include <bits/stdc++.h>
const int inf = 1e9 + 7;
const int N = 1e5 + 50;
int minn, wz, n, x, ans;
int main() {
  scanf("%d", &n);
  minn = inf;
  ans = n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (minn == x && ans > i - wz) ans = i - wz;
    if (minn == x) wz = i;
    if (minn > x) minn = x, wz = i, ans = n;
  }
  printf("%d\n", ans);
}
