#include<bits/stdc++.h>
using namespace std;
int main(){
int t; cin>>t;
while(t--){
int n;
cin >> n;
int A[n];
for (int i = 0; i < n; i++) cin >> A[i];
int cnter = 1;
while (!is_sorted(A, A + n)) {
if (cnter % 2) {
for (int i = 0; i < n - 1; i++) {
if (((i + 1) % 2) and A[i] > A[i + 1])
swap(A[i], A[i + 1]);
}
}
else {
for (int i = 0; i < n - 1; i++) {
if (!((i + 1) % 2) and A[i] > A[i + 1])
swap(A[i], A[i + 1]);
}
}
cnter++;
}
cout << cnter - 1<< endl;
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKXsKICAgIGludCB0OyBjaW4+PnQ7CiAgICB3aGlsZSh0LS0pewogICAgaW50IG47CiAgICBjaW4gPj4gbjsKICAgIGludCBBW25dOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIGNpbiA+PiBBW2ldOwogICAgaW50IGNudGVyID0gMTsKICAgIHdoaWxlICghaXNfc29ydGVkKEEsIEEgKyBuKSkgewogICAgICAgIGlmIChjbnRlciAlIDIpIHsKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuIC0gMTsgaSsrKSB7CiAgICAgICAgICAgICAgICBpZiAoKChpICsgMSkgJSAyKSBhbmQgQVtpXSA+IEFbaSArIDFdKQogICAgICAgICAgICAgICAgICAgIHN3YXAoQVtpXSwgQVtpICsgMV0pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGVsc2UgewogICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG4gLSAxOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmICghKChpICsgMSkgJSAyKSBhbmQgQVtpXSA+IEFbaSArIDFdKQogICAgICAgICAgICAgICAgICAgIHN3YXAoQVtpXSwgQVtpICsgMV0pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNudGVyKys7CiAgICB9CiAgICBjb3V0IDw8IGNudGVyIC0gMTw8IGVuZGw7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==