#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 07;
const long long mxn = 1e15 + 10;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long i, j, a, b, c, d, n, m, t, h, u, v;
  cin >> n;
  long long mn1 = mxn, mn2 = mxn;
  map<long long, long long> pos;
  for (i = 1; i <= n; i++) {
    cin >> m;
    if (pos[m]) {
      long long gap = i - pos[m];
      if (m < mn1) {
        mn1 = m;
        mn2 = gap;
      } else if (m == mn1) {
        mn2 = min(mn2, gap);
      }
    }
    pos[m] = i;
  }
  cout << mn2 << endl;
  return 0;
}
