#include <bits/stdc++.h>
using namespace std;
int main() {
  long int b;
  cin >> b;
  long long int a[b];
  for (int i = 0; i < b; i++) {
    cin >> a[i];
  }
  long long int min = a[0];
  for (int i = 0; i < b; i++) {
    if (min > a[i]) min = a[i];
  }
  long int c = -1;
  long int d = -1;
  int e = 0;
  long int f = b;
  for (int i = 0; i < b; i++) {
    if (a[i] == min) {
      if (e == 0) {
        c = i;
        e += 1;
      } else if (e == 1) {
        d = i;
        e = 0;
      }
      if ((d != -1) && (f > abs(d - c))) {
        f = abs(d - c);
      }
    }
  }
  cout << f;
  return 0;
}
