#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    int m1 = 0;
    for (long long i = 0; i < n; i++) {
      map<long long, long long> m;
      int check = 1;
      int ctr = 0;
      for (long long j = 0; j < i; j++) {
        m[a[j]]++;
        if (m[a[j]] > 1) {
          break;
          check = 0;
        }
        ctr++;
      }
      if (check == 0) break;
      for (long long j = n - 1; j >= i; j--) {
        m[a[j]] += 1;
        if (m[a[j]] > 1) break;
        ctr++;
      }
      m1 = max(m1, ctr);
    }
    cout << (n - m1);
  }
}
