There is a bookshelf which can fit $n$ books. The $i$-th position of bookshelf is $a_i = 1$ if there is a book on this position and $a_i = 0$ otherwise. It is guaranteed that there is at least one book on the bookshelf.

In one move, you can choose some contiguous segment $[l; r]$ consisting of books (i.e. for each $i$ from $l$ to $r$ the condition $a_i = 1$ holds) and:  Shift it to the right by $1$: move the book at index $i$ to $i + 1$ for all $l \le i \le r$. This move can be done only if $r+1 \le n$ and there is no book at the position $r+1$.  Shift it to the left by $1$: move the book at index $i$ to $i-1$ for all $l \le i \le r$. This move can be done only if $l-1 \ge 1$ and there is no book at the position $l-1$. 

Your task is to find the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without any gaps).

For example, for $a = [0, 0, 1, 0, 1]$ there is a gap between books ($a_4 = 0$ when $a_3 = 1$ and $a_5 = 1$), for $a = [1, 1, 0]$ there are no gaps between books and for $a = [0, 0,0]$ there are also no gaps between books.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 200$) — the number of test cases. Then $t$ test cases follow.

The first line of the test case contains one integer $n$ ($1 \le n \le 50$) — the number of places on a bookshelf. The second line of the test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 1$), where $a_i$ is $1$ if there is a book at this position and $0$ otherwise. It is guaranteed that there is at least one book on the bookshelf.


-----Output-----

For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).


-----Example-----
Input
5
7
0 0 1 0 1 0 1
3
1 0 0
5
1 1 0 0 1
6
1 0 0 0 0 1
5
1 1 0 1 1

Output
2
0
2
4
1



-----Note-----

In the first test case of the example, you can shift the segment $[3; 3]$ to the right and the segment $[4; 5]$ to the right. After all moves, the books form the contiguous segment $[5; 7]$. So the answer is $2$.

In the second test case of the example, you have nothing to do, all the books on the bookshelf form the contiguous segment already.

In the third test case of the example, you can shift the segment $[5; 5]$ to the left and then the segment $[4; 4]$ to the left again. After all moves, the books form the contiguous segment $[1; 3]$. So the answer is $2$.

In the fourth test case of the example, you can shift the segment $[1; 1]$ to the right, the segment $[2; 2]$ to the right, the segment $[6; 6]$ to the left and then the segment $[5; 5]$ to the left. After all moves, the books form the contiguous segment $[3; 4]$. So the answer is $4$.

In the fifth test case of the example, you can shift the segment $[1; 2]$ to the right. After all moves, the books form the contiguous segment $[2; 5]$. So the answer is $1$.

Difficulty: introductory

Starter code:

Solutions:
for _ in range(int(input())):
	n=int(input())
	s=list(map(int,input().split()))
	l=s.index(1)
	r=n-s[::-1].index(1)
	ans=0
	for i in range(l,r):
		ans+=1-s[i]
	print(ans)

def solve():
    n = int(input())
    lst = list(map(int,input().split()))
    while len(lst) > 0 and lst[-1] == 0:
        lst.pop()
    od = False
    ans = 0
    for i in lst:
        if i == 0 and od:
            ans += 1
        if i == 1:
            od = True
    print(ans)
for i in range(int(input())):
    solve()

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    alst = list(map(int, input().split()))
    flg = False
    ans = 0
    for i, a in enumerate(alst):
        if a == 1:
            if not flg:
                flg = True
            else:
                ans += i - bef - 1
            bef = i
        
    print(ans)
for _ in range(int(input())):
    main()

#   ==========     //\\       //||     ||====//||
#       ||        //  \\        ||     ||   // ||
#       ||       //====\\       ||     ||  //  ||
#       ||      //      \\      ||     || //   ||
#   ========== //        \\  ========  ||//====|| 
#  code


def solve():
    n = int(input())
    a = list(map(int, input().split()))

    last = -1
    ans = 0
    for i, v in enumerate(a):
        if v == 1:
            if last > -1:
                ans += i - last - 1
            last = i
    print(ans)

def main():
    t = 1
    t = int(input())
    for _ in range(t):
        solve()

def __starting_point():
    main()
__starting_point()

for t in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    z = a.count(0)
    j = 0
    while j < n and a[j] != 1:
        j += 1
        z -= 1
    j = n - 1
    while j >= 0 and a[j] != 1:
        j -= 1
        z -= 1    
    print(z)

t = int(input())
#
for _ in range(t):
    n = int(input())
    arr = [int(val) for val in input().split(' ')]
    arr_idx = [idx for idx, val in enumerate(arr) if val]
    c = 0
    for i in range(len(arr_idx)-1):
        c += arr_idx[i+1] - arr_idx[i] - 1
    print(c)


from math import *
from bisect import *
from collections import *
from random import *
from decimal import *
from itertools import *
import sys
input=sys.stdin.readline
def inp():
    return int(input())
def st():
    return input().rstrip('\n')
def lis():
    return list(map(int,input().split()))
def ma():
    return list(map(int,input().split()))
t=inp()
while(t):
    t-=1
    n=inp()
    a=lis()
    while(len(a) and a[-1]==0):
        a.pop()
    a=a[::-1]
    while(len(a) and a[-1]==0):
        a.pop()
    print(a.count(0))




for _ in range(int(input())):
	n=int(input())
	a=list(map(int,input().split()))

	i=0
	while a[i]==0:
		i+=1

	j=n-1
	while a[j]==0:
		j-=1

	print(a[i:j+1].count(0))


for __ in range(int(input())):
    n = int(input())
    ar = list(map(int, input().split()))
    ans = ar.count(0)
    i = 0
    while ar[i] == 0:
        ans -= 1
        i += 1
    j = n - 1
    while ar[j] == 0 and i != j:
        ans -= 1
        j -= 1
    print(max(0, ans))

import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
import string


ORDA = 97  # a
def ii(): return int(input())
def mi(): return list(map(int, input().split()))
def li(): return [int(i) for i in input().split()]
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def revn(n): return str(n)[::-1]
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r
def divs(n, start=2):
    r = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if (n % i == 0):
            if (n / i == i):
                r.append(i)
            else:
                r.extend([i, n // i])
    return r
def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
def prime(n):
    if n == 2: return True
    if n % 2 == 0 or n <= 1: return False
    sqr = int(math.sqrt(n)) + 1
    for d in range(3, sqr, 2):
        if n % d == 0: return False
    return True
def convn(number, base):
    new_number = 0
    while number > 0:
        new_number += number % base
        number //= base
    return new_number
def cdiv(n, k): return n // k + (n % k != 0)
def ispal(s):
    for i in range(len(s) // 2 + 1):
        if s[i] != s[-i - 1]:
            return False
    return True


for _ in range(ii()):
    n = ii()
    a = li()
    s = ''.join(map(str, a))
    s = s.strip('0')
    print(s.count('0'))


for k in range(int(input())):
    n = int(input())
    vec = list(map(int, input().split()))
    while vec[0] == 0:
        vec = vec[1::]
    while vec[-1] == 0:
        vec = vec[:-1:]
    print(vec.count(0))

t=int(input())
for _ in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    left=-1
    right=-1
    for i in range(n):
        if a[i]==1:
            left=i
            break
    if left==-1:
        print(0)
        continue
    for i in range(n-1,-1,-1):
        if a[i]==1:
            right=i
            break
    count1=0
    for i in range(n):
        if a[i]==1:
            count1+=1
    print(right-left-count1+1)

import math
import string
import random
from random import randrange
from collections import deque
from collections import defaultdict

def solve(n, arr):
    ans = 0

    st = 0
    while st<n and arr[st] == 0:
        st += 1
        
    ed = n-1
    while ed>=0 and arr[ed] == 0:
        ed -= 1
        
    if st == n or ed == -1:
        print(0)
        return
    
    for i in range(st, ed+1):
        if arr[i] == 0:
            ans += 1

    print(ans)
    return 

def main():
    t = int(input())
    while t>0:
        t-=1
        
        n = int(input())
        # s = input().strip()
        # x,y = map(int, input().strip().split(" "))
        arr = list(map(int, input().strip().split(" ")))
        
        solve(n, arr)
        
    return

def test():
    arr_size = 25
    test_cases = 100
    min_range = -100
    max_range = 100
    str_size = 30
    step = 1
    
    for i in range(test_cases):
        k = []
        # s = ''.join(random.choices(string.ascii_lowercase, k = str_size))
        
        for j in range(arr_size):
            num = randrange(min_range, max_range, step)
            k.append(num)
        
        solve(n, arr)
        print("<-------- DEBUG ----------->")

    return 

def __starting_point():
    main()
    # test()
        

__starting_point()

rn=lambda:int(input())
rl=lambda:list(map(int,input().split()))
rns=lambda:map(int,input().split())
rs=lambda:input()
yn=lambda x:print('Yes') if x else print('No')
YN=lambda x:print('YES') if x else print('NO')

for _ in range(rn()):
    n=rn()
    l=rl()
    ans=0
    start=False
    acc=0
    for i in l:
        if i==1:
            start=True
            ans+=acc
            acc=0
        elif start:
            acc+=1
    print(ans)

for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))

    z = 0
    l = -1

    c = 0

    for i in range(n):
        if a[i] == 0:
            z += 1

        else:
            if l != -1:
                c += z

            l = i

            z = 0

    print(c)


def testcase():

    n = int(input())
    arr = list(map(int, input().split()))
    i = 0
    while i < n:
        if arr[i] == 1:
            break
        i += 1
    i += 1
    ans = 0
    zs = 0
    while i < n:
        if arr[i] == 0:
            zs += 1
        else:
            ans += zs
            zs = 0
        i += 1
    print(ans)
    return


import sys, os
if os.path.exists('input.txt'):
    sys.stdin = open('input.txt', 'r')
t = int(input())
for _ in range(t):
    testcase()

t = int(input())
for i10 in range (t):
    n = int(input())
    a = list(map(int, input().split()))
    k = 0
    s = 0
    e = 0
    for i in range(n):
        if a[i] == 1:
            if e == 1:
                s += k
            e = 1
            k = 0
        else:
            k += 1
    print(s)
        


#!/usr/bin/env pypy3

def ans(books):
    i = None
    j = None
    for k in range(len(books)):
        if books[k] == 0: continue
        j = k
        if i is None:
            i = k

    return sum(1-x for x in books[i:j+1])

for _ in range(int(input())):
    input()
    books = list(map(int, input().split()))
    print(ans(books))

for _ in range(int(input())):
    am = int(input())
    arr = list(map(int,input().split()))
    fl = False
    l = 0
    r = am
    for i in range(am):
        if arr[i] == 1:
            l = i
            break
    for i in range(am-1,-1,-1):
        if arr[i] == 1:
            r = i
            break
    print(arr[l:r].count(0))

for _ in range(int(input())):
    n = input()
    s = input().replace(" ","").lstrip("0").rstrip("0")
    print(s.count("0"))

import sys,math,itertools
from collections import Counter,deque,defaultdict
from bisect import bisect_left,bisect_right 
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

for _ in range(inp()):
    n = inp()
    a = inpl()
    st = la = 0
    for i in range(n):
        if a[i]:
            st = i
            break
    for i in range(n)[::-1]:
        if a[i]:
            la = i
            break

    ch = False
    res = 0
    for i in range(st,la+1):
        x = a[i]
        if ch:
            if x: continue
            ch = False
            res += 1
        else:
            if x: ch = True
            else:
                res += 1
    print(res)

t=int(input())
for _ in range(t):
    n=int(input())
    l=list(map(int,input().split()))
    i=0
    j=n-1
    while i<n and l[i]==0:
        i+=1
    while j>=0 and l[j]==0:
        j-=1
    ans=0
    while i<=j:
        if l[i]==0:
            ans+=1
        else:
            pass
        i+=1
    print(ans)


t = int(input())
while t:
    t -= 1
    n = input()
    a = [int(i) for i in input().split()]
    fb = -1
    lb = -1
    c = 0
    for i in range(len(a)):
        if a[i] == 1:
            if fb == -1:
                fb = i
            lb = i
            c += 1
    print(lb - fb - c + 1)


for _ in range(int(input())):
    x = int(input())
    r = [int(x) for x in input().split()]

    is_s = False
    last_z = 0
    tot = 0
    for i in r:
        if i == 1:
            if not is_s:
                is_s=True
                last_z = 0
            else:
                last_z = 0
        else:
            if is_s:
                last_z+=1
                tot+=1
    print(tot-last_z)

import sys


def read(func=int):
    return func(sys.stdin.readline().strip())

def readList(func=int):
    return list(map(func, sys.stdin.readline().strip().split()))


t = read()

for _ in range(t):
    n = read()
    A = readList()
    ri = -1
    for i in range(n - 1, -1, -1):
        if A[i]:
            ri = i
            break
    count = 0
    start = False
    for i in range(n):
        num = A[i]
        if num == 1:
            start = True
        if num == 0 and start and i < ri:
            count += 1

    print(count)