#include <bits/stdc++.h>
double EPS = 0.0000001;
const long long INF = 1000000007;
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int mn = INF;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mn = min(mn, a[i]);
  }
  vector<int> m;
  for (int i = 0; i < n; i++)
    if (a[i] == mn) m.push_back(i);
  int ans = INF;
  for (int i = 0; i < m.size() - 1; i++) ans = min(ans, m[i + 1] - m[i]);
  cout << ans;
  return 0;
}
