#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int minVal = INT_MAX, res = INT_MAX;
  for (int i = 0; i < n; ++i) {
    minVal = min(minVal, a[i]);
  }
  stack<int> st;
  for (int i = 0; i < n; ++i) {
    if (a[i] == minVal) {
      if (!st.empty()) {
        res = min(res, i - st.top());
      }
      st.push(i);
    }
  }
  cout << res;
  return 0;
}
