#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  map<long long int, bool> exist;
  int ans = n;
  for (int i = 0; i < n; i++) {
    int l;
    for (l = 0; l < i; l++) {
      if (exist[a[l]])
        break;
      else
        exist[a[l]] = true;
    }
    int r;
    for (r = (n - 1); r >= i; r--) {
      if (exist[a[r]])
        break;
      else
        exist[a[r]] = true;
    }
    if (l == i) ans = min(ans, (r - l) + 1);
    exist.clear();
  }
  cout << ans;
}
