#include <bits/stdc++.h>   using namespace std;   int main() {     vector<int> v;     vector<int>::iterator it;     int n, q, x, count1 = 0, x1;     cin >> q;     while (q--) {       cin >> n;       while (n--) {         cin >> x;         v.push_back(x);       }       it = v.end() - 1;       x1 = *it;       for (it = v.end() - 2; it >= v.begin(); it--) {         if (*it > x1)           count1++;         else           x1 = *it;       }       cout << count1 << endl;       count1 = 0;       v.clear();     }   }   