#include #include #include #include #include #include #include #include #include #include #include #define MOD 1000000007 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define ABS(a) (((a) > (0)) ? (a) : (-(a))) using namespace std; int a[20], n, ans; int main() { int t; scanf("%d", &t); while(t--) { scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d", &a[i]); ans = n; int tmp = n; for(int i = n - 1; i >= 0; i--) if(a[i] == ans) { ans--; } printf("%d\n", ans); } return 0; }