#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b % 2 == 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b /= 2;
  }
  return res;
}
bool comp(long long int a, long long int b) { return a < b; }
long long int binary(long long int *a, long long int l, long long int r,
                     long long int key) {
  long long int mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (a[mid] == key) {
      return mid;
    } else if (a[mid] < key) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return -1;
}
bool isprime(long long int n) {
  if (n <= 1) {
    return false;
  }
  int i;
  for (i = 2; i <= ceil(sqrt((double)n)); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
bool isPalindrome(long long int n) {
  long long int rev = 0, temp = n, rem;
  while (temp) {
    rem = temp % 10;
    rev = rev * 10 + rem;
    temp /= 10;
  }
  if (n == rev) return true;
  return false;
}
long long int mulmod(long long int a, long long int b, long long int m) {
  long long int res = 0;
  a = a % m;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res + a) % m;
    }
    a = (a * 2) % m;
    b /= 2;
  }
  return (res % m);
}
bool isLeapYear(int year) {
  if (year % 400 == 0) return true;
  if (year % 100 == 0) return false;
  if (year % 4 == 0) return true;
  return false;
}
int ones(long long int n) {
  int ans = 0;
  while (n) {
    ans++;
    n &= (n - 1);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t, pro = 1, n, m, temp, k, i, l, r, mid, j, x, y, z, ind,
                   mx = LONG_LONG_MIN, mn = LONG_LONG_MAX, ans = 0, cnt = 0,
                   curr = 0, prev, sum = 0, flag = 0, i1 = -1, i2 = -1;
  cin >> n;
  long long int a[n];
  for (i = 0; i <= n - 1; i++) {
    cin >> a[i];
    mn = min(mn, a[i]);
  }
  vector<long long int> v;
  for (i = 0; i <= n - 1; i++) {
    if (a[i] == mn) {
      v.push_back(i);
    }
  }
  ans = LONG_LONG_MAX;
  for (i = 0; i <= v.size() - 2; i++) {
    ans = min(ans, v[i + 1] - v[i]);
  }
  cout << ans;
  return 0;
}
