description: You have a permutation: an array a = [a_1, a_2, …, a_n] of distinct integers from 1 to n. The length of the permutation n is odd.
  
  Consider the following algorithm of sorting the permutation in increasing order.
  
  A helper procedure of the algorithm, f(i), takes a single argument i (1 ≤ i ≤ n-1) and does the following. If a_i > a_{i+1}, the values of a_i and a_{i+1} are exchanged. Otherwise, the permutation doesn't change.
  
  The algorithm consists of iterations, numbered with consecutive integers starting with 1. On the i-th iteration, the algorithm does the following: 
  
    * if i is odd, call f(1), f(3), …, f(n - 2); 
    * if i is even, call f(2), f(4), …, f(n - 1). 
  
  
  
  It can be proven that after a finite number of iterations the permutation will be sorted in increasing order.
  
  After how many iterations will this happen for the first time?
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.
  
  The first line of each test case contains a single integer n (3 ≤ n ≤ 999; n is odd) — the length of the permutation.
  
  The second line contains n distinct integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — the permutation itself. 
  
  It is guaranteed that the sum of n over all test cases does not exceed 999.
  
  Output
  
  For each test case print the number of iterations after which the permutation will become sorted in increasing order for the first time.
  
  If the given permutation is already sorted, print 0.
  
  Example
  
  Input
  
  
  3
  3
  3 2 1
  7
  4 5 7 1 3 2 6
  5
  1 2 3 4 5
  
  
  Output
  
  
  3
  5
  0
  
  Note
  
  In the first test case, the permutation will be changing as follows: 
  
    * after the 1-st iteration: [2, 3, 1]; 
    * after the 2-nd iteration: [2, 1, 3]; 
    * after the 3-rd iteration: [1, 2, 3]. 
  
  
  
  In the second test case, the permutation will be changing as follows: 
  
    * after the 1-st iteration: [4, 5, 1, 7, 2, 3, 6]; 
    * after the 2-nd iteration: [4, 1, 5, 2, 7, 3, 6]; 
    * after the 3-rd iteration: [1, 4, 2, 5, 3, 7, 6]; 
    * after the 4-th iteration: [1, 2, 4, 3, 5, 6, 7]; 
    * after the 5-th iteration: [1, 2, 3, 4, 5, 6, 7]. 
  
  
  
  In the third test case, the permutation is already sorted and the answer is 0.
solution: import java.util.*;
  import java.io.*;
  public class sortings {
  	static Scanner sc=new Scanner(System.in);
  	static PrintWriter pw=new PrintWriter(System.out);
  	static BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
  	public static boolean isSorted(int []a) {
  		for(int i=0;i<a.length-1;i++) {
  			if(a[i+1]<a[i])
  				return false;
  		}
  		return true;
  	}
  	public static void main(String []args) throws IOException {
  	int t=sc.nextInt();
  	while(t-->0) {
  		int n=sc.nextInt();
  		int [] a=sc.nextIntArray(n);
  		int ans=0;
  		for(int i=0;i<n && !isSorted(a);i++) {
  			int start=i%2==0?0:1;
  			for(int j=start;j<n-1;j+=2) {
  				if(a[j+1]<a[j]) {
  					int temp=a[j];
  					a[j]=a[j+1];
  					a[j+1]=temp;
  				}
  			}
  			ans++;
  			//pw.println(Arrays.toString(a)+" "+ans);
  		}
  		pw.println(ans);
  	}
  		
  	pw.flush();
  	}
  		
  	/*static long count;
  	public static void merge(int []a,int start,int mid,int end) {
  		int []b=new int[end-start+1];
  		int ind1=start,ind2=mid+1;
  		int cur=0;
  		while(ind1<mid+1 || ind2<end+1) {
  			if(ind1==mid+1) {
  				for(;ind2<end+1;ind2++) {
  					b[cur++]=a[ind2];
  					
  				}
  			}
  			else if(ind2==end+1) {
  				for(;ind1<mid+1;ind1++) {
  					b[cur++]=a[ind1];
  				}
  			}
  			else {
  				if(a[ind1]>a[ind2]) {
  					b[cur++]=a[ind2++];
  					count+=mid-ind1+1;
  				}
  				else {
  					b[cur++]=a[ind1++];
  				
  				}
  			}
  		}
  		for(int i=0;i<b.length;i++) {
  			a[i+start]=b[i];
  		}
  	}
  	public static void sort(int []a,int start,int end ) {
  		if(end==start)
  			return;
  		int mid=(start+end)/2;
  		sort(a, start, mid);
  		sort(a, mid+1, end);
  		merge(a, start, mid, end);
  		//pw.println(Arrays.toString(s));
  	}
  	public static void mergesort(int []a) {
  		sort(a, 0, a.length-1);
  	}
  	static long count2=0;
  	public static void insertionSort(int []a) {
  		int n=a.length;
  		for(int i=1;i<n;i++) {
  			int j=i-1;
  			int key=a[i];
  			while(j>-1 && a[j]>key) {
  				a[j+1]=a[j];
  				j--;
  				//count2++;
  			}
  			a[j+1]=key;
  			
  		}
  	}*/
  	static class pair implements Comparable<pair> {
  		long x;
  		long y;
   
  		public pair(long x, long y) {
  			this.x = x;
  			this.y = y;
  		}
   
  		public String toString() {
  			return x + " " + y;
  		}
   
  		public boolean equals(Object o) {
  			if (o instanceof pair) {
  				pair p = (pair) o;
  				return p.x == x && p.y == y;
  			}
  			return false;
  		}
   
  		public int hashCode() {
  			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
  		}
   
  		public int compareTo(pair other) {
  			if (this.x == other.x) {
  				return Long.compare(this.y, other.y);
  			}
  			return Long.compare(this.x, other.x);
  		}
  	}
  	static class Scanner {
  		StringTokenizer st;
  		BufferedReader br;
   
  		public Scanner(InputStream s) {
  			br = new BufferedReader(new InputStreamReader(s));
  		}
   
  		public Scanner(FileReader r) {
  			br = new BufferedReader(r);
  		}
  		public String readAllLines(BufferedReader reader) throws IOException {
  		    StringBuilder content = new StringBuilder();
  		    String line;
  		    
  		    while ((line = reader.readLine()) != null) {
  		        content.append(line);
  		        content.append(System.lineSeparator());
  		    }
  
  		    return content.toString();
  		}
  		public String next() throws IOException {
  			while (st == null || !st.hasMoreTokens())
  				st = new StringTokenizer(br.readLine());
  			return st.nextToken();
  		}
   
  		public int nextInt() throws IOException {
  			return Integer.parseInt(next());
  		}
   
  		public long nextLong() throws IOException {
  			return Long.parseLong(next());
  		}
   
  		public String nextLine() throws IOException {
  			return br.readLine();
  		}
   
  		public double nextDouble() throws IOException {
  			String x = next();
  			StringBuilder sb = new StringBuilder("0");
  			double res = 0, f = 1;
  			boolean dec = false, neg = false;
  			int start = 0;
  			if (x.charAt(0) == '-') {
  				neg = true;
  				start++;
  			}
  			for (int i = start; i < x.length(); i++)
  				if (x.charAt(i) == '.') {
  					res = Long.parseLong(sb.toString());
  					sb = new StringBuilder("0");
  					dec = true;
  				} else {
  					sb.append(x.charAt(i));
  					if (dec)
  						f *= 10;
  				}
  			res += Long.parseLong(sb.toString()) / f;
  			return res * (neg ? -1 : 1);
  		}
   
  		public long[] nextlongArray(int n) throws IOException {
  			long[] a = new long[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextLong();
  			return a;
  		}
   
  		public Long[] nextLongArray(int n) throws IOException {
  			Long[] a = new Long[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextLong();
  			return a;
  		}
   
  		public int[] nextIntArray(int n) throws IOException {
  			int[] a = new int[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextInt();
  			return a;
  		}
   
  		public Integer[] nextIntegerArray(int n) throws IOException {
  			Integer[] a = new Integer[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextInt();
  			return a;
  		}
   
  		public boolean ready() throws IOException {
  			return br.ready();
  		}
   
  	}
  }
  /*String s=br.readLine();
  while(s.charAt(0)!='0') {
  	String [] temp=s.split(" ");
  	int []a=new int [temp.length];
  	for(int i=0;i<temp.length;i++) {
  		a[i]=Integer.parseInt(temp[i]);
  	}
  	int c=0;
  	while(!checker(a)) {
  		for(int i=0;i<a.length-1;i++) {
  			if(a[i]>a[i+1]) {
  				int temp2=a[i];
  				a[i]=a[i+1];
  				a[i+1]=temp2;
  				c++;
  				break;
  			}
  		}
  	}
  	if(c%2==0)
  		pw.println("Carlos");
  	else 
  		pw.println("Marcelo");
  	pw.println(c);
  	s=br.readLine();
  }*/