#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
  int n, mini, temp;
  cin >> n;
  cin >> mini;
  int minindex = 0, maxindex = 0, flag = 1;
  for (int i = 1; i < n; i++) {
    cin >> temp;
    if (mini == temp) {
      maxindex = i;
      a[flag] = i;
      flag++;
    }
    if (temp < mini) {
      mini = temp;
      minindex = i;
      maxindex = i;
      flag = 0;
      a[flag] = i;
      flag++;
    }
  }
  sort(a, a + flag);
  for (int i = 0; i < flag - 1; i++) a[i] = a[i + 1] - a[i];
  temp = a[0];
  for (int i = 1; i < flag - 1; i++) {
    if (temp > a[i]) temp = a[i];
  }
  cout << temp;
  return 0;
}
