#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  std::copy_n(std::istream_iterator<int>{std::cin}, n, a.begin());
  auto it1 = std::min_element(a.cbegin(), a.cend());
  auto it_to_end = std::find(it1 + 1, a.cend(), *it1);
  int ans = it_to_end - it1;
  do {
    if (it_to_end - it1 < ans) ans = it_to_end - it1;
    it1 = it_to_end;
    it_to_end = std::find(it1 + 1, a.cend(), *it1);
  } while (it_to_end != a.cend());
  std::cout << ans << '\n';
}
