#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, mx = LLONG_MAX, ans = LLONG_MAX, mn = LLONG_MAX;
  vector<long long> a(100005);
  map<long long, long long> m;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i], mn = min(mn, a[i]);
  for (long long i = 1; i <= n; i++) {
    if (m[a[i]] > 0 && a[i] == mn) ans = i - m[a[i]];
    m[a[i]] = i;
    mx = min(mx, ans);
  }
  cout << mx;
}
