human
Can you solve the below in PYTHON3?
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...
 What is a Python code to print the number of iterations after which the permutation will become sorted in increasing order for the first time?
assistant
#Here is Python code to print the number of iterations after which the permutation will become sorted in increasing order for the first time.

import bisect
import heapq
import math
import collections
import sys
import copy
from functools import reduce
import decimal
from io import BytesIO, IOBase
import os
import itertools
import functools
from types import GeneratorType

sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP

graphDict = collections.defaultdict

queue = collections.deque

################## pypy deep recursion handling ##############
# Author = @pajenegod
def bootstrap(f, stack=[]):
    def wrappedfunc(*args, **kwargs):
        to = f(*args, **kwargs)
        if stack:
            return to
        else:
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        return to
                    to = stack[-1].send(to)

    return wrappedfunc

################## Graphs ###################
class Graphs:
    def __init__(self):
        self.graph = graphDict(set)

    def add_edge(self, u, v):
        self.graph[u].add(v)
        self.graph[v].add(u)

    def dfs_utility(self, nodes, visited_nodes, psf):
        global ans
        if len(visited_nodes.keys()) == n:
            ans = psf
            return
        visited_nodes[nodes] = None
        for neighbour in self.graph[nodes]:
            if neighbour not in visited_nodes:
                self.dfs_utility(neighbour, visited_nodes, psf + [neighbour])
        visited_nodes.pop(nodes)
        return

    def dfs(self, node):
        global ans
        Visited = collections.OrderedDict()
        self.dfs_utility(node, Visited, [node])

    def bfs(self, node):
        visited = set()
        if node not in visited:
            queue.append(node)
            visited.add(node)
        while queue:
            parent = queue.popleft()
            print(parent)
            for item in self.graph[parent]:
                if item not in visited:
                   ...