#include <bits/stdc++.h>
int main() {
  int n, min = 1000000005, k, mindis = 1000000005, x1;
  scanf("%d", &n);
  x1 = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &k);
    if (k < min) {
      min = k;
      mindis = 1000000005;
      x1 = i;
    } else if (k == min) {
      if (x1 != 0) {
        if (i - x1 < mindis) mindis = i - x1;
        x1 = i;
      }
    }
  }
  printf("%d", mindis);
}
