#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int minn = 1000000010;
  int min_dist = n;
  int min_index = 0;
  vector<int> arr(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    if (arr[i] < minn) {
      minn = arr[i];
    }
  }
  vector<int> a;
  for (int i = 0; i < n; ++i) {
    if (arr[i] == minn) {
      a.push_back(i);
    }
  }
  for (int i = 1; i < a.size(); ++i) {
    if (min_dist > a[i] - a[i - 1]) {
      min_dist = a[i] - a[i - 1];
    }
  }
  cout << min_dist << endl;
  return 0;
}
