#include <bits/stdc++.h>
using namespace std;
long long powa(int x, int y) {
  if (y == 0) return 1;
  long long ans = x;
  for (int i = 2; i <= y; i++) {
    ans = ans * x;
  }
  return ans;
}
int ara[100010];
int mark[100010];
int main() {
  int n;
  scanf("%d", &n);
  int minn = 1000000010;
  for (int i = 1, _b = (n); i <= _b; i++) {
    int a;
    scanf("%d", &a);
    minn = min(minn, a);
    ara[i] = a;
  }
  for (int j = 1, _b = (n); j <= _b; j++) {
    if (ara[j] == minn) mark[j] = 1;
  }
  int pos1;
  for (int k = 1, _b = (n); k <= _b; k++) {
    if (mark[k] == 1) {
      pos1 = k;
      break;
    }
  }
  int dist, mindist = 1000000010;
  for (int k = pos1 + 1, _b = (n); k <= _b; k++) {
    if (mark[k] == 1) {
      dist = k - pos1;
      pos1 = k;
      mindist = min(mindist, dist);
    }
  }
  printf("%d\n", mindist);
  return 0;
}
