#include <bits/stdc++.h>
using namespace std;
const int N = 200200;
const int mod = 1e9 + 7;
int n, a[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  int mn = *min_element(a + 1, a + n + 1);
  int last = -1;
  int res = 1e9;
  for (int i = 1; i <= n; ++i)
    if (a[i] == mn) {
      if (last != -1) res = min(res, i - last);
      last = i;
    }
  cout << res;
  return 0;
}
