#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  int min = 1000000001;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (min > a[i]) min = a[i];
  }
  vector<int> occ;
  for (int i = 1; i <= n; i++) {
    if (a[i] == min) occ.push_back(i);
  }
  min = (n - 1);
  for (int i = 0; i < occ.size() - 1; i++) {
    if ((occ[i + 1] - occ[i]) < min) min = occ[i + 1] - occ[i];
  }
  cout << min << endl;
}
