CODEM3 - Problem3

Arrays are one of the most basic and widely used data structures. While data structures like stack, queues, linked list etc are often considered as advanced, so we will be playing with arrays only at the moment. So let us play a simple game. We play the game as follows: You will be given an array of integers and you can swap any two elements of the given array at a time. Swapping cost is 1 unit. The aim of the game is to append all zeros if present in the array to the end while keeping order of its element.

Find the minimum cost to obtain the aim of the game.

Input

First line contains a number T. (number of test cases)
For each test case 2 lines follow,
First line contains size of array, n <= 10^6.
Second line contains the array elements. (-10^9 <= value of elements <= 10^9)

Output

For each test case print on separate line the minimum cost to obtain the aim.

Example

Input:
3
4
1 3 0 2
4
1 2 3 0
4
1 2 3 5 Output: 1
0
0

Explanation

For first case swap 0 and 2, so the array becomes 1 3 2 0. Hence all zeros at the end and order of elements is preserved. (i.e. 1 was before 3, 3 was after 1 and before 2 and so on. )


Added by:Bhavik
Date:2014-02-04
Time limit:0.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C C++ 4.3.2
Resource:own problem(for CODE MARATHON)

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.