#include <bits/stdc++.h>
using namespace std;
long long n;
struct Node1 {
  long long id;
  long long x;
} a[100005];
bool cmp(Node1 a, Node1 b) {
  if (a.x == b.x)
    return a.id < b.id;
  else
    return a.x < b.x;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].x;
    a[i].id = i;
  }
  sort(a, a + n, cmp);
  long long ansx = a[0].x;
  long long ansid = 0x7FFFFFFF;
  for (int i = 0; i < n; i++) {
    if (a[i].x != ansx || a[i + 1].x != ansx) break;
    ansid = min(a[i + 1].id - a[i].id, ansid);
  }
  cout << ansid << endl;
  return 0;
}
