#include <bits/stdc++.h>
using namespace std;
const int Maxx = 1e6 + 5;
char s[55];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  int t, n, flag = 0, posta, cnt, posend;
  cin >> t;
  while (t--) {
    flag = 0, posta = 0, cnt = 0, posend = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> s[i];
    }
    for (int i = 1; i <= n; i++) {
      if (s[i] == '1' && !flag) {
        posta = i;
        flag = 1;
      }
      if (flag && s[i] == '1') {
        posend = i;
      }
    }
    for (int i = posta; i < posend; i++) {
      if (s[i] == '0') ++cnt;
    }
    cout << cnt << endl;
  }
}
