func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[2010], b[2010];   bool vis[2010];   char *p1, *p2, buf[100000];   int rd() {     int x = 0, f = 1;     char c =         (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)              ? EOF              : *p1++);     while (c < 48) {       if (c ==  - ) f = -1;       c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)                ? EOF                : *p1++);     }     while (c > 47) {       x = (((x << 2) + x) << 1) + (c ^ 48),       c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)                ? EOF                : *p1++);     }     return x * f;   }   map<int, int> MP;   int n;   bool check(int x) {     for (int i = 1; i <= n - x + 1; i++) {       memset(vis, false, sizeof vis);       bool flag = true;       for (int j = 1; j < i; j++) {         if (vis[a[j]]) {           flag = false;         }         vis[a[j]] = true;       }       for (int j = i + x; j <= n; j++) {         if (vis[a[j]]) {           flag = false;         }         vis[a[j]] = true;       }       if (flag) {         return true;       }     }     return false;   }   int main() {     n = rd();     for (int i = 1; i <= n; i++) {       a[i] = rd();       b[i] = a[i];     }     sort(b + 1, b + n + 1);     b[0] = b[1] - 1;     int cnt = 0;     for (int i = 1; i <= n; i++) {       if (b[i] != b[i - 1]) {         MP[b[i]] = ++cnt;       }     }     for (int i = 1; i <= n; i++) {       a[i] = MP[a[i]];     }     if (cnt == n) {       puts( 0 );       return 0;     }     int ans = n;     int l = 1, r = n;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid)) {         ans = mid;         r = mid - 1;       } else {         l = mid + 1;       }     }     cout << ans << endl;   }   