#include <bits/stdc++.h>
using namespace std;
struct node {
  int id;
  int no;
} a[100001];
int n, tot = 1, minn = 2100000000;
bool cmp(node a, node b) {
  if (a.no != b.no) return a.no < b.no;
  return a.id < b.id;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].no);
    a[i].id = i;
  }
  sort(a + 1, a + n + 1, cmp);
  while (a[tot].no == a[tot + 1].no) {
    minn = min(minn, a[tot + 1].id - a[tot].id);
    tot++;
  }
  printf("%d", minn);
  return 0;
}
