#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   template <class T>   using V = vector<T>;   template <typename T>   using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;   long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }   long long LCM(long long a, long long b) { return a / GCD(a, b) * b; }   long long int pom(long long int a, long long int n, int m) {     long long int x = 1;     for (a %= m; n; n /= 2) n& 1 ? x = x * a % m : 0, a = a * a % m;     return x;   }   int dx[4] = {-1, 0, 1, 0};   int dy[4] = {0, -1, 0, 1};   int ddx[8] = {-1, 0, 1, 0, 1, 1, -1, -1};   int ddy[8] = {0, -1, 0, 1, 1, -1, 1, -1};   long long int cmp1(pair<pair<long long int, long long int>, long long int> a,                      pair<pair<long long int, long long int>, long long int> b) {     return a.first.second > b.first.second;   }   long long int cmp2(pair<long long int, long long int> a,                      pair<long long int, long long int> b) {     if (a.second != b.second)       return a.second < b.second;     else       return a.first > b.first;   }   int main(int argc, char* argv[]) {     cin.tie(0);     ios::sync_with_stdio(false);     long long int T;     cin >> T;     while (T--) {       long long int n;       cin >> n;       V<long long int> a(n + 1);       for (long long int i = 0; i < n; i++) {         cin >> a[i];       }       long long int ans = 0;       bool abc = 0;       long long int cnt = 0;       for (long long int i = 1; i < n; i++) {         if (a[i - 1] == 1 && a[i] == 0) {           abc = 1;           cnt = 1;         } else if (abc == 1 && a[i] == 0) {           cnt++;         }         if (abc == 1 && (a[i] == 0 && a[i + 1] == 1 && i < n - 1)) {           ans += cnt;           cnt = 0;           abc = 0;         }       }       cout << ans << endl;     }     return 0;   }   