#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5 + 4;
int a[NMAX];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int mn = 1e9 + 4;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    mn = min(mn, a[i]);
  }
  vector<int> res;
  for (int i = 0; i < n; ++i) {
    if (a[i] == mn) {
      res.push_back(i);
    }
  }
  int ans = 1e6 + 4;
  for (int i = 0; i < res.size() - 1; ++i) {
    ans = min(ans, (res[i + 1] - res[i]));
  }
  cout << ans;
  return 0;
}
