#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a[100000];
  long long n, min, ans = -1;
  long long idx = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 1; i < n; ++i)
    if (a[i] < a[idx]) idx = i;
  min = a[idx];
  for (int i = idx + 1; i < n; ++i)
    if (a[i] == min) {
      if (i - idx < ans || ans == -1) ans = i - idx;
      idx = i;
    }
  cout << ans;
}
