func_code_string: #include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   const long double pi = acos(-1.0);   const long double eps = 1e-5;   const int INF = 0x3f3f3f3f;   const long long INFLL = 0x3f3f3f3f3f3f3f3f;   int a[300010];   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       map<int, int> l;       map<int, int> r;       for (int i = (1); i <= (n); i++) {         cin >> a[i];         if (!l[a[i]]) l[a[i]] = i;         r[a[i]] = i;       }       int ans = l.size();       int p = 0;       int cnt = 0;       int res = 0;       for (auto it : l) {         if (p < it.second)           cnt++;         else           cnt = 1;         p = r[it.first];         res = max(res, cnt);       }       cout << ans - res <<   n ;     }     return 0;   }   