#include <bits/stdc++.h>
using namespace std;
int lol[100002];
int main() {
  int n, nr, i, m;
  cin >> n >> m;
  lol[0] = 1;
  lol[1] = 0;
  for (i = 1; i < n; i++) {
    cin >> nr;
    if (nr == m)
      lol[++lol[0]] = i;
    else if (nr < m) {
      m = nr;
      lol[0] = 1;
      lol[1] = i;
    }
  }
  nr = lol[2] - lol[1];
  for (i = 3; i <= lol[0]; i++)
    if (lol[i] - lol[i - 1] < nr) nr = lol[i] - lol[i - 1];
  cout << nr;
  return 0;
}
