#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, i, k, x = 0, y = 0, a, j = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a;
    if (x >= a || x == 0) {
      if (x == a)
        k = min(i - j, k);
      else
        k = i - j;
      x = a;
      if (x <= y || y == 0) {
        swap(x, y);
        j = i;
      }
    }
  }
  cout << k;
}
