#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
void solve(int cs) {
int n;
cin >> n;
vector <int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int res = 0;
for (int i = 0; i < n; i++) {
if (a[i] == 1) {
int j = i;
for (; i < n; i++) {
if (a[i] == 2) {
break;
} else if (a[i] == 3) {
res = max(res, i - j + 1);
}
}
}
}
cout << res << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tc = 1;
cin >> tc;
for (int cs = 1; cs <= tc; cs++) {
solve(cs);
}
return 0;
}