#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> mp;
const int maxn = 1e5 + 1;
int a[maxn], mn = 1e9;
int main() {
  int n, x, ans = 1e9;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mn = min(mn, a[i]);
  }
  for (int i = 1; i <= n; i++)
    if (mn == a[i]) {
      if (mp.count(a[i])) ans = min(ans, i - mp[a[i]]);
      mp[a[i]] = i;
    }
  cout << ans;
}
