#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, min1, ras = INT_MAX;
  cin >> n;
  int a[n];
  queue<int> v;
  cin >> a[0];
  min1 = a[0];
  v.push(0);
  for (int i = 1; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    if (min1 > a[i]) {
      while (!v.empty()) {
        v.pop();
      }
      v.push(i);
      min1 = a[i];
    } else {
      if (min1 == a[i] && v.size() == 2) {
        int kek = v.front();
        v.pop();
        ras = min(ras, v.front() - kek);
        v.push(i);
      }
      if (min1 == a[i] && v.size() == 1) {
        ras = i - v.front();
        v.push(i);
      }
    }
  }
  int kol = v.front();
  v.pop();
  ras = min(v.front() - kol, ras);
  cout << ras;
}
