1556_B. Take Your Places!_158
<image>

William has an array of n integers a_1, a_2, ..., a_n. In one move he can swap two neighboring items. Two items a_i and a_j are considered neighboring if the condition |i - j| = 1 is satisfied.

William wants you to calculate the minimal number of swaps he would need to perform to make it so that the array does not contain two neighboring items with the same parity.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.

The first line of each test case contains an integer n (1 ≤ n ≤ 10^5) which is the total number of items in William's array.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) which are William's array.

It is guaranteed that the sum of n over all test cases does not exceed 10^5.

Output

For each test case output the minimal number of operations needed or -1 if it is impossible to get the array to a state when no neighboring numbers have the same parity.

Example

Input


5
3
6 6 1
1
9
6
1 1 1 2 2 2
2
8 6
6
6 2 3 4 5 1


Output


1
0
3
-1
2

Note

In the first test case the following sequence of operations would satisfy the requirements: 

  1. swap(2, 3). Array after performing the operation: [6, 1, 6] 



In the second test case the array initially does not contain two neighboring items of the same parity.

In the third test case the following sequence of operations would satisfy the requirements: 

  1. swap(3, 4). Array after performing the operation: [1, 1, 2, 1, 2, 2] 
  2. swap(2, 3). Array after performing the operation: [1, 2, 1, 1, 2, 2] 
  3. swap(4, 5). Array after performing the operation: [1, 2, 1, 2, 1, 2] 



In the fourth test case it is impossible to satisfy the requirements.

In the fifth test case the following sequence of operations would satisfy the requirements: 

  1. swap(2, 3). Array after performing the operation: [6, 3, 2, 4, 5, 1] 
  2. swap(4, 5). Array after performing the operation: [6, 3, 2, 5, 4, 1] 

import javax.rmi.ssl.SslRMIClientSocketFactory;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import java.io.*;
import java.sql.ResultSetMetaData;
import java.text.DecimalFormat;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
       Reader.init(System.in);
       BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
       output.flush();
       int t = Reader.nextInt();
       while ( t > 0){
            int n = Reader.nextInt();
            int array[] = new int[n];
            int i = 0;
            int eve = 0;
            int odd = 0;
            ArrayList<Integer> eveI = new ArrayList<>();
            ArrayList<Integer> oddI = new ArrayList<>();
            while (i < n){
                array[i] = Reader.nextInt();
                if ( (array[i]&1) == 1){
                    oddI.add(i+1);
                    odd++;
                }
                else{
                    eveI.add(i+1);
                    eve++;
                }
                i++;
            }
            if ( n%2 == 0 && eve != odd){
                System.out.println(-1);
            }
            else if ( n%2 == 0){
                long a = abs(calculate(oddI,n));
                long b = abs(calculate(eveI,n));
                System.out.println(Math.min(a,b));
            }
            else if ( n%2 == 1){
                int M = max(odd,eve);
                int mid = n/2 +1;
                if ( M != mid){
                    System.out.println(-1);
                }
                else{
                    if ( M == odd){
                        System.out.println(abs(calculate(oddI,n)));
                    }
                    else{
                        System.out.println(abs(calculate(eveI,n)));
                    }
                }
            }
            t--;
       }
       output.flush();
    }

    private static long calculate(ArrayList<Integer> array,int n){
        int i = 1;
        long count = 0;
        while ( i <= n){
            if ( (i&1) == 1){
                int v = array.remove(0);
                count+= abs(v-i);
            }
            i++;
        }
        return  count;
    }

    private static int bs(int low,int high,int[] array,int find){
        if ( low <= high ){
            int  mid = low + (high-low)/2;
            if ( array[mid] > find){
                high = mid -1;
                return bs(low,high,array,find);
            }
            else if ( array[mid] < find){
                low = mid+1;
                return bs(low,high,array,find);
            }
            return mid;
        }
        return -1;
    }

    private static int max(int a, int b) {
        return  Math.max(a,b);
    }

    private static int min(int a,int b){
        return  Math.min(a,b);
    }

    public static long modularExponentiation(long a,long b,long mod){
        if ( b == 1){
            return a;
        }
        else{
            long ans = modularExponentiation(a,b/2,mod)%mod;
            if ( b%2 == 1){
                return (a*((ans*ans)%mod))%mod;
            }

            return ((ans*ans)%mod);
        }
    }

    public static long sum(long n){
        return  (n*(n+1))/2;
    }
    public static long abs(long a){
        return a < 0 ? (-1*a) : a;
    }
    public static long gcd(long a,long b){
        if ( a == 0){
            return b;
        }
        else{
            return gcd(b%a,a);
        }
    }


}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;


    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {

            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static long nextLong() throws IOException{
        return Long.parseLong(next());
    }
}

class NComparator implements Comparator<Node>{
    @Override
    public int compare(Node o1, Node o2) {
       if ( o1.value> o2.value){
           return  1;
       }
       else if ( o2.value > o1.value){
           return -1;
       }
       else{
           if ( o1.index < o2.index){
               return  1;
           }
           else if ( o1.index > o2.index){
               return -1;
           }
           else{
               return 0;
           }
       }
    }
}

class Node{
    int value;
    int length;
    int index;

    Node(int v,int l,int i){
        value = v;
        length = l;
        index = i;
    }


}