#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n;
  vector<int> arr(n);
  int mn = 1000000007;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mn = min(mn, arr[i]);
  }
  int ans = n + 1;
  int prev = -1;
  for (int i = 0; i < n; i++) {
    if (arr[i] == mn) {
      if (prev != -1) {
        ans = min(ans, i - prev);
      }
      prev = i;
    }
  }
  cout << ans;
  return 0;
}
