Skip to content

1778

A_Flip_Flop_Sum

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def solve():
    n = int(input())
    ar = list(map(int, input().split()))
    res = sum(ar)

    for i in range(n - 1):
        if ar[i] == ar[i + 1] == -1:
            print(res + 4)
            return
    if res == n:
        res -= 4
    print(res)


for _ in range(int(input())):
    solve()