#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int mod = 1e9 + 7;
bool prime[1000001];
void sieve() {
  memset(prime, true, sizeof(prime));
  for (long long int i = 2; i * i <= 1000000; i++)
    if (prime[i])
      for (long long int j = i * i; j <= 1000000; j += i) prime[j] = false;
  prime[0] = prime[1] = false;
}
long long int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0, cnt5 = 0, ans1 = 0,
              ans2 = 0, ans3 = 0;
void solve() {
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > v1;
  for (long long int i = 0; i < n; i++) {
    long long int a1;
    cin >> a1;
    v1.push_back(make_pair(a1, i));
  }
  sort((v1).begin(), (v1).end());
  long long int z1 = v1[0].first;
  set<long long int> st1;
  long long int z2 = 0;
  while (v1[z2].first == z1) {
    st1.insert(v1[z2].second);
    z2++;
  }
  long long int ans = INT_MAX;
  vector<long long int> v2;
  for (auto it : st1) {
    v2.push_back(it);
  }
  for (long long int i = 0; i < v2.size() - 1; i++) {
    ans = min(ans, (v2[i + 1] - v2[i]));
  }
  cout << ans << endl;
  return;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
