#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ia = -1, min = 100000;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  m = *min_element(a, a + n);
  for (int i = 0; i < n; ++i) {
    if (a[i] == m && ia == -1)
      ia = i;
    else if (a[i] == m && ia != -1) {
      if (i - ia < min) {
        min = i - ia;
      }
      ia = i;
    }
  }
  cout << min << endl;
  return 0;
}
