#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m = 0, sum = 0;
  cin >> n;
  int a[n];
  map<int, int> mp, tmp;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
    if (mp[a[i]] > 1) {
      m++;
      sum = INT_MAX;
    }
  }
  for (int i = 0; i < n; i++) {
    tmp = mp;
    int x = m, idx = i;
    for (int j = i; j < n; j++) {
      if (tmp[a[j]] > 1) {
        tmp[a[j]]--;
        x--;
        idx = j;
      }
    }
    if (x == 0) {
      sum = min(sum, idx - i + 1);
    }
  }
  cout << sum << endl;
  return 0;
}
