#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h = 0, u = 10000009, i, ar[100009], m = 1000000009, d = 10000009,
         mo = 1000000009, p[100009], s = 10000009;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ar[i];
    if (ar[i] < m) m = ar[i];
  }
  for (i = 0; i < n; i++) {
    if (ar[i] == m) {
      p[h++] = i;
      if (h > 1) u = min(u, p[h - 1] - p[h - 2]);
    }
  }
  if (h > 1)
    cout << u << endl;
  else {
    h = 0;
    for (i = 0; i < n; i++) {
      if (ar[i] < mo && ar[i] > m) {
        mo = ar[i];
      }
    }
    for (i = 0; i < n; i++) {
      if (ar[i] == mo) u = min(u, abs(i - p[0]));
    }
    cout << u << endl;
  }
  return 0;
}
