#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	// your code goes here
	int t, n, k, temp, count;
	scanf("%d", &t);
	while(t--) {
		scanf("%d", &n);
		count=0;
		for(int i=0; i<n; i++) {
			scanf("%d", &k); if(i==0) temp=k;
			if(k<=temp) {
				temp=k; count++;
			}
		}
		cout<<count<<endl;
	}
	return 0;
}