#include <bits/stdc++.h>
using namespace std;
int n, a[100002];
int main() {
  int i, mi = 1000000007, ans = 100002, j;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < mi) mi = a[i];
  }
  bool flag = false;
  for (i = 0; i < n; i++) {
    if (a[i] != mi) continue;
    if (!flag)
      flag = true;
    else if (i - j < ans)
      ans = i - j;
    j = i;
  }
  cout << ans << endl;
  return 0;
}
