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$.
[{"code": "for _ in range(int(input())):\n\tn=int(input())\n\ts=list(map(int,input().split()))\n\tl=s.index(1)\n\tr=n-s[::-1].index(1)\n\tans=0\n\tfor i in range(l,r):\n\t\tans+=1-s[i]\n\tprint(ans)", "passed": true, "time": 0.16, "memory": 14328.0, "status": "done"}, {"code": "def solve():\n    n = int(input())\n    lst = list(map(int,input().split()))\n    while len(lst) > 0 and lst[-1] == 0:\n        lst.pop()\n    od = False\n    ans = 0\n    for i in lst:\n        if i == 0 and od:\n            ans += 1\n        if i == 1:\n            od = True\n    print(ans)\nfor i in range(int(input())):\n    solve()", "passed": true, "time": 0.15, "memory": 14288.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\n\ndef main():\n    n = int(input())\n    alst = list(map(int, input().split()))\n    flg = False\n    ans = 0\n    for i, a in enumerate(alst):\n        if a == 1:\n            if not flg:\n                flg = True\n            else:\n                ans += i - bef - 1\n            bef = i\n        \n    print(ans)\nfor _ in range(int(input())):\n    main()", "passed": true, "time": 1.0, "memory": 14128.0, "status": "done"}, {"code": "#   ==========     //\\\\       //||     ||====//||\n#       ||        //  \\\\        ||     ||   // ||\n#       ||       //====\\\\       ||     ||  //  ||\n#       ||      //      \\\\      ||     || //   ||\n#   ========== //        \\\\  ========  ||//====|| \n#  code\n\n\ndef solve():\n    n = int(input())\n    a = list(map(int, input().split()))\n\n    last = -1\n    ans = 0\n    for i, v in enumerate(a):\n        if v == 1:\n            if last > -1:\n                ans += i - last - 1\n            last = i\n    print(ans)\n\ndef main():\n    t = 1\n    t = int(input())\n    for _ in range(t):\n        solve()\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.15, "memory": 14288.0, "status": "done"}, {"code": "for t in range(int(input())):\n    n = int(input())\n    a = list(map(int, input().split()))\n    z = a.count(0)\n    j = 0\n    while j < n and a[j] != 1:\n        j += 1\n        z -= 1\n    j = n - 1\n    while j >= 0 and a[j] != 1:\n        j -= 1\n        z -= 1    \n    print(z)", "passed": true, "time": 0.14, "memory": 14020.0, "status": "done"}, {"code": "t = int(input())\n#\nfor _ in range(t):\n    n = int(input())\n    arr = [int(val) for val in input().split(' ')]\n    arr_idx = [idx for idx, val in enumerate(arr) if val]\n    c = 0\n    for i in range(len(arr_idx)-1):\n        c += arr_idx[i+1] - arr_idx[i] - 1\n    print(c)\n", "passed": true, "time": 0.14, "memory": 14060.0, "status": "done"}, {"code": "\n\nfor _ in range(int(input())):\n\tn=int(input())\n\ta=list(map(int,input().split()))\n\n\ti=0\n\twhile a[i]==0:\n\t\ti+=1\n\n\tj=n-1\n\twhile a[j]==0:\n\t\tj-=1\n\n\tprint(a[i:j+1].count(0))\n", "passed": true, "time": 0.15, "memory": 14144.0, "status": "done"}, {"code": "for __ in range(int(input())):\n    n = int(input())\n    ar = list(map(int, input().split()))\n    ans = ar.count(0)\n    i = 0\n    while ar[i] == 0:\n        ans -= 1\n        i += 1\n    j = n - 1\n    while ar[j] == 0 and i != j:\n        ans -= 1\n        j -= 1\n    print(max(0, ans))", "passed": true, "time": 0.23, "memory": 14084.0, "status": "done"}, {"code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\nimport string\n\n\nORDA = 97  # a\ndef ii(): return int(input())\ndef mi(): return list(map(int, input().split()))\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n    if n < 2: return list()\n    prime = [True for _ in range(n + 1)]\n    p = 3\n    while p * p <= n:\n        if prime[p]:\n            for i in range(p * 2, n + 1, p):\n                prime[i] = False\n        p += 2\n    r = [2]\n    for p in range(3, n + 1, 2):\n        if prime[p]:\n            r.append(p)\n    return r\ndef divs(n, start=2):\n    r = []\n    for i in range(start, int(math.sqrt(n) + 1)):\n        if (n % i == 0):\n            if (n / i == i):\n                r.append(i)\n            else:\n                r.extend([i, n // i])\n    return r\ndef divn(n, primes):\n    divs_number = 1\n    for i in primes:\n        if n == 1:\n            return divs_number\n        t = 1\n        while n % i == 0:\n            t += 1\n            n //= i\n        divs_number *= t\ndef prime(n):\n    if n == 2: return True\n    if n % 2 == 0 or n <= 1: return False\n    sqr = int(math.sqrt(n)) + 1\n    for d in range(3, sqr, 2):\n        if n % d == 0: return False\n    return True\ndef convn(number, base):\n    new_number = 0\n    while number > 0:\n        new_number += number % base\n        number //= base\n    return new_number\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s):\n    for i in range(len(s) // 2 + 1):\n        if s[i] != s[-i - 1]:\n            return False\n    return True\n\n\nfor _ in range(ii()):\n    n = ii()\n    a = li()\n    s = ''.join(map(str, a))\n    s = s.strip('0')\n    print(s.count('0'))\n", "passed": true, "time": 0.15, "memory": 14212.0, "status": "done"}, {"code": "for k in range(int(input())):\n    n = int(input())\n    vec = list(map(int, input().split()))\n    while vec[0] == 0:\n        vec = vec[1::]\n    while vec[-1] == 0:\n        vec = vec[:-1:]\n    print(vec.count(0))", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "t=int(input())\nfor _ in range(t):\n    n=int(input())\n    a=list(map(int,input().split()))\n    left=-1\n    right=-1\n    for i in range(n):\n        if a[i]==1:\n            left=i\n            break\n    if left==-1:\n        print(0)\n        continue\n    for i in range(n-1,-1,-1):\n        if a[i]==1:\n            right=i\n            break\n    count1=0\n    for i in range(n):\n        if a[i]==1:\n            count1+=1\n    print(right-left-count1+1)", "passed": true, "time": 0.14, "memory": 14060.0, "status": "done"}, {"code": "import math\nimport string\nimport random\nfrom random import randrange\nfrom collections import deque\nfrom collections import defaultdict\n\ndef solve(n, arr):\n    ans = 0\n\n    st = 0\n    while st<n and arr[st] == 0:\n        st += 1\n        \n    ed = n-1\n    while ed>=0 and arr[ed] == 0:\n        ed -= 1\n        \n    if st == n or ed == -1:\n        print(0)\n        return\n    \n    for i in range(st, ed+1):\n        if arr[i] == 0:\n            ans += 1\n\n    print(ans)\n    return \n\ndef main():\n    t = int(input())\n    while t>0:\n        t-=1\n        \n        n = int(input())\n        # s = input().strip()\n        # x,y = map(int, input().strip().split(\" \"))\n        arr = list(map(int, input().strip().split(\" \")))\n        \n        solve(n, arr)\n        \n    return\n\ndef test():\n    arr_size = 25\n    test_cases = 100\n    min_range = -100\n    max_range = 100\n    str_size = 30\n    step = 1\n    \n    for i in range(test_cases):\n        k = []\n        # s = ''.join(random.choices(string.ascii_lowercase, k = str_size))\n        \n        for j in range(arr_size):\n            num = randrange(min_range, max_range, step)\n            k.append(num)\n        \n        solve(n, arr)\n        print(\"<-------- DEBUG ----------->\")\n\n    return \n\ndef __starting_point():\n    main()\n    # test()\n        \n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14260.0, "status": "done"}, {"code": "rn=lambda:int(input())\nrl=lambda:list(map(int,input().split()))\nrns=lambda:map(int,input().split())\nrs=lambda:input()\nyn=lambda x:print('Yes') if x else print('No')\nYN=lambda x:print('YES') if x else print('NO')\n\nfor _ in range(rn()):\n    n=rn()\n    l=rl()\n    ans=0\n    start=False\n    acc=0\n    for i in l:\n        if i==1:\n            start=True\n            ans+=acc\n            acc=0\n        elif start:\n            acc+=1\n    print(ans)", "passed": true, "time": 0.14, "memory": 14380.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    n = int(input())\n    a = list(map(int, input().split()))\n\n    z = 0\n    l = -1\n\n    c = 0\n\n    for i in range(n):\n        if a[i] == 0:\n            z += 1\n\n        else:\n            if l != -1:\n                c += z\n\n            l = i\n\n            z = 0\n\n    print(c)\n", "passed": true, "time": 0.14, "memory": 14304.0, "status": "done"}, {"code": "def testcase():\n\n    n = int(input())\n    arr = list(map(int, input().split()))\n    i = 0\n    while i < n:\n        if arr[i] == 1:\n            break\n        i += 1\n    i += 1\n    ans = 0\n    zs = 0\n    while i < n:\n        if arr[i] == 0:\n            zs += 1\n        else:\n            ans += zs\n            zs = 0\n        i += 1\n    print(ans)\n    return\n\n\nimport sys, os\nif os.path.exists('input.txt'):\n    sys.stdin = open('input.txt', 'r')\nt = int(input())\nfor _ in range(t):\n    testcase()", "passed": true, "time": 0.14, "memory": 14280.0, "status": "done"}, {"code": "t = int(input())\nfor i10 in range (t):\n    n = int(input())\n    a = list(map(int, input().split()))\n    k = 0\n    s = 0\n    e = 0\n    for i in range(n):\n        if a[i] == 1:\n            if e == 1:\n                s += k\n            e = 1\n            k = 0\n        else:\n            k += 1\n    print(s)\n        \n", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "#!/usr/bin/env pypy3\n\ndef ans(books):\n    i = None\n    j = None\n    for k in range(len(books)):\n        if books[k] == 0: continue\n        j = k\n        if i is None:\n            i = k\n\n    return sum(1-x for x in books[i:j+1])\n\nfor _ in range(int(input())):\n    input()\n    books = list(map(int, input().split()))\n    print(ans(books))", "passed": true, "time": 0.14, "memory": 14192.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    am = int(input())\n    arr = list(map(int,input().split()))\n    fl = False\n    l = 0\n    r = am\n    for i in range(am):\n        if arr[i] == 1:\n            l = i\n            break\n    for i in range(am-1,-1,-1):\n        if arr[i] == 1:\n            r = i\n            break\n    print(arr[l:r].count(0))", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    n = input()\n    s = input().replace(\" \",\"\").lstrip(\"0\").rstrip(\"0\")\n    print(s.count(\"0\"))", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "import sys,math,itertools\nfrom collections import Counter,deque,defaultdict\nfrom bisect import bisect_left,bisect_right \nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nfor _ in range(inp()):\n    n = inp()\n    a = inpl()\n    st = la = 0\n    for i in range(n):\n        if a[i]:\n            st = i\n            break\n    for i in range(n)[::-1]:\n        if a[i]:\n            la = i\n            break\n\n    ch = False\n    res = 0\n    for i in range(st,la+1):\n        x = a[i]\n        if ch:\n            if x: continue\n            ch = False\n            res += 1\n        else:\n            if x: ch = True\n            else:\n                res += 1\n    print(res)", "passed": true, "time": 0.14, "memory": 14132.0, "status": "done"}, {"code": "t=int(input())\nfor _ in range(t):\n    n=int(input())\n    l=list(map(int,input().split()))\n    i=0\n    j=n-1\n    while i<n and l[i]==0:\n        i+=1\n    while j>=0 and l[j]==0:\n        j-=1\n    ans=0\n    while i<=j:\n        if l[i]==0:\n            ans+=1\n        else:\n            pass\n        i+=1\n    print(ans)\n", "passed": true, "time": 0.22, "memory": 14220.0, "status": "done"}, {"code": "t = int(input())\nwhile t:\n    t -= 1\n    n = input()\n    a = [int(i) for i in input().split()]\n    fb = -1\n    lb = -1\n    c = 0\n    for i in range(len(a)):\n        if a[i] == 1:\n            if fb == -1:\n                fb = i\n            lb = i\n            c += 1\n    print(lb - fb - c + 1)\n", "passed": true, "time": 0.14, "memory": 14372.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    x = int(input())\n    r = [int(x) for x in input().split()]\n\n    is_s = False\n    last_z = 0\n    tot = 0\n    for i in r:\n        if i == 1:\n            if not is_s:\n                is_s=True\n                last_z = 0\n            else:\n                last_z = 0\n        else:\n            if is_s:\n                last_z+=1\n                tot+=1\n    print(tot-last_z)", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "import sys\n\n\ndef read(func=int):\n    return func(sys.stdin.readline().strip())\n\ndef readList(func=int):\n    return list(map(func, sys.stdin.readline().strip().split()))\n\n\nt = read()\n\nfor _ in range(t):\n    n = read()\n    A = readList()\n    ri = -1\n    for i in range(n - 1, -1, -1):\n        if A[i]:\n            ri = i\n            break\n    count = 0\n    start = False\n    for i in range(n):\n        num = A[i]\n        if num == 1:\n            start = True\n        if num == 0 and start and i < ri:\n            count += 1\n\n    print(count)\n\n", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}]