#include <bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main() {
  long long n, i;
  long long mini;
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    if (i == 0) {
      mini = arr[i];
    } else {
      mini = ((arr[i] >= mini) ? (mini) : (arr[i]));
    }
  }
  long long minidist;
  vector<long long> vec;
  for (i = 0; i < n; i++) {
    if (arr[i] == mini) {
      vec.push_back(i);
    }
  }
  sort(vec.begin(), vec.end());
  minidist = vec[1] - vec[0];
  for (i = 2; i < vec.size(); i++) {
    minidist = ((minidist >= (vec[i] - vec[i - 1])) ? ((vec[i] - vec[i - 1]))
                                                    : (minidist));
  }
  printf("%lld\n", minidist);
  return 0;
}
