#include <bits/stdc++.h>
using namespace std;
int cnt[100100 + 1];
const int mod = 998244353;
bool prime[100100];
vector<int> v;
void solve() {
  int n;
  cin >> n;
  int a[n];
  map<int, vector<int>> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]].push_back(i + 1);
  }
  int mn = INT_MAX;
  for (auto i : m) {
    vector<int> v;
    v = i.second;
    for (int i = 1; i < v.size(); i++) {
      int tmp = v[i] - v[i - 1];
      mn = min(mn, tmp);
    }
    break;
  }
  cout << mn << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}
