#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) {
    bool flag = true, cond = true;
    long long int n, i, j, x, y = 0, ind, k, m, dif, mn = INT_MAX, p = 0,
                              mx = 0, count = 0, diff, y1;
    cin >> n;
    vector<long long int> a(n);
    for (i = 0; i < n; i++) cin >> a[i];
    map<long long int, long long int> mp1;
    vector<long long int> res;
    for (i = 0; i < n; i++) {
      cond = true;
      mp1.clear();
      for (j = 0; j < i; j++) {
        if (mp1[a[j]] == 0)
          mp1[a[j]]++;
        else {
          cond = false;
          res.push_back(j);
          break;
        }
      }
      if (cond) {
        for (j = n - 1; j >= i; j--) {
          if (mp1[a[j]] == 0) {
            mp1[a[j]]++;
            if (j == i) res.push_back(mp1.size());
          } else {
            res.push_back(mp1.size());
            break;
          }
        }
      }
    }
    cout << n - *max_element(res.begin(), res.end());
  }
  return 0;
}
