#include using namespace std; using ll = long long; #define rep(i,n) for (int i=0;i<(int)(n);i++) map,bool> mp={ {{0,0,0},0}, {{0,0,1},1}, {{0,1,0},0}, {{0,1,1},1}, {{1,0,0},1}, {{1,0,1},0}, {{1,1,0},1}, {{1,1,1},0}, {{0,0,0,0},0}, {{0,0,0,1},1}, {{0,0,1,0},0}, {{0,0,1,1},1}, {{0,1,0,0},0}, {{0,1,0,1},1}, {{0,1,1,0},1}, {{0,1,1,1},1}, {{1,0,0,0},1}, {{1,0,0,1},1}, {{1,0,1,0},1}, {{1,0,1,1},0}, {{1,1,0,0},1}, {{1,1,0,1},0}, {{1,1,1,0},1}, {{1,1,1,1},0}, }; void solve(){ int n; cin>>n; vector a(n); rep(i,n) cin>>a.at(i); if(a.at(0)) rep(i,n) a.at(i)^=1; if(a.back()){ cout<<"Yes\n"; return; } rep(i,n-1){ if(a.at(i)&&a.at(i+1)){ cout<<"Yes\n"; return; } } int ct=0; rep(i,n) ct+=a.at(i); if(ct>=4) cout<<"Yes\n"; else cout<<"No\n"; } int main(){ int t; cin>>t; rep(i,t) solve(); }