func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = INT_MAX;   void solve() {     long long n;     cin >> n;     vector<long long> a(n);     vector<long long> first(n, INF);     vector<long long> last(n, -INF);     for (long long i = 0; i < n; ++i) {       cin >> a[i];       --a[i];       first[a[i]] = min(first[a[i]], i);       last[a[i]] = max(last[a[i]], i);     }     sort(a.begin(), a.end());     a.erase(unique(a.begin(), a.end()), a.end());     long long now = 0;     long long mx = 0;     long long ans = 0;     n = a.size();     for (long long i = 0; i < n; ++i) {       if (i) {         if (first[a[i]] > mx)           ++now;         else           now = 1;         mx = last[a[i]];         ans = max(ans, now);       } else {         now = 1;         mx = max(mx, last[a[i]]);         ans = max(ans, now);       }     }     cout << a.size() - ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long q;     cin >> q;     while (q--) solve();     return 0;   }   