#include <bits/stdc++.h>
using namespace std;
map<int, int> M;
int n;
int main() {
  cin >> n;
  int res = 1e9;
  int mx = 1e9;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (M[a] == 0)
      M[a] = i;
    else {
      if (mx > a) {
        mx = a;
        res = i - M[a];
      } else if (mx == a) {
        res = min(res, i - M[a]);
      }
      M[a] = i;
    }
  }
  cout << res << endl;
}
