#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> list(n, 0);
  int min = -1;
  for (int i = 0; i < n; i++) {
    cin >> list[i];
    if (min == -1 || list[i] < min) min = list[i];
  }
  int mindist = -1;
  int previx = -1;
  for (int i = 0; i < n; i++) {
    if (list[i] == min) {
      if (previx != -1) {
        if (mindist == -1 || i - previx < mindist) {
          mindist = i - previx;
        }
      }
      previx = i;
    }
  }
  cout << mindist << endl;
  return 0;
}
