#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int ans = 0;
        for(int i = 0;i<n;i++){
            int a;
            cin>>a;
            ans += a;
        }
        ans = n - ans;
        if(ans==0) ans = 1;
        else ans--;
        cout<<ans<<endl;
    }

}