#include <bits/stdc++.h>
using namespace std;
long long res = 100007 * 100007, j, m = 100007 * 100007, n, a[100007];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    m = min(m, a[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == m) {
      if (j != 0) {
        res = min(i - j, res);
      }
      j = i;
    }
  }
  cout << res << endl;
  return 0;
}
