fork download
  1. # your code goes here
  2. t = int(input())
  3.  
  4. for _ in range(t):
  5. n = int(input())
  6. arr = list(map(int,input().split()))
  7. p = arr.index(1)
  8. for i in range(len(arr)):
  9. if(arr[i]==1 and (i-p)!=0):
  10. if(i-p <= 6):
  11. ans = "NO"
  12. p = i
  13. else:
  14. ans = "YES"
  15. p = i
  16. print(ans)
Success #stdin #stdout 0.02s 9352KB
stdin
3
3
1 0 1
7
1 0 0 0 0 0 1
11
0 1 0 0 0 0 0 1 0 0 1
stdout
NO
NO
NO