func_code_string: #include <bits/stdc++.h>      #define fi first   #define se second   #define mp make_pair      using namespace std;   using ll = long long;   using pii = pair<int, int>;      constexpr double eps = 1e-8;   constexpr int NINF = 0xc0c0c0c0;   constexpr int INF = 0x3f3f3f3f;   constexpr ll mod = 1e9 + 7;   constexpr ll N = 1e6 + 5;      int n, a[N], f[N], l[N], r[N], cnt[N];      int main() {       ios::sync_with_stdio(false);       cin.tie(nullptr);          cin >> n;       for (int i = 1; i <= n; i++) {           cin >> a[i];           if (!l[a[i]]) l[a[i]] = i;       }       for (int i = n; i; i--) {           if (!r[a[i]]) r[a[i]] = i;       }       for (int i = n; i; i--) {           cnt[a[i]]++;           if (i == l[a[i]]) {               f[i] = max(cnt[a[i]] + f[r[a[i]] + 1], f[i + 1]);           } else {               f[i] = max(cnt[a[i]], f[i + 1]);           }       }       cout << n - f[1] <<   n ;          return 0;   }