#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<long long int, int> > v;
  for (int i = 0; i < n; i++) {
    long long int a;
    cin >> a;
    v.push_back({a, i});
  }
  sort(v.begin(), v.end());
  int minn = 1000000;
  for (int i = 1; i < v.size(); i++) {
    if (v[i].first != v[i - 1].first)
      break;
    else {
      minn = min(minn, abs(v[i].second - v[i - 1].second));
    }
  }
  cout << minn;
}
