#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, a, flag, ans, d, c, mm, arr[200005];
  while (scanf("%lld", &n) == 1) {
    ans = 1000000010;
    for (i = 0; i < n; i++) {
      scanf("%lld", &arr[i]);
      if (ans > arr[i]) {
        mm = arr[i];
        ans = arr[i];
      }
    }
    flag = 0;
    ans = 1000000010;
    for (i = 0; i < n; i++) {
      if (arr[i] == mm && flag == 0) {
        c = i;
        flag = 1;
        i++;
      }
      if (flag == 1 && mm == arr[i]) {
        a = i - c;
        if (ans > a) ans = a;
        c = i;
      }
    }
    if (n == 1)
      cout << "0" << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
