var loc,cas,xx,n,i,j:longint; a:array[0..1010]of longint; begin readln(cas); for xx:=1 to cas do begin readln(n); for i:=1 to n do read(a[i]); readln; loc:=n; for i:=n downto 1 do if a[i]=loc then dec(loc); writeln(loc); end; end.