public static void main ( String args [ ] ) {
  try {
    Scanner sc = new Scanner ( System . in ) ;
    int T = sc . nextInt ( ) ;
    System . out . println ( ) ;
    while ( T > 0 ) {
      int A [ ] = new int [ T ] ;
      for ( int i = 0 ;
      i < T ;
      i ++ ) {
        A [ i ] = sc . nextInt ( ) ;
      }
      int B [ ] = new int [ 2 * T ] ;
      for ( int i = 0 ;
      i < T ;
      i ++ ) {
        B [ i ] = A [ i ] ;
      }
      for ( int i = T ;
      i < 2 * T ;
      i ++ ) {
        B [ i ] = A [ i - T ] ;
      }
      int count = 0 ;
      int result = 0 ;
      for ( int i = 0 ;
      i < 2 * T ;
      i ++ ) {
        if ( B [ i ] == 0 ) {
          count = 0 ;
        }
        else {
          count ++ ;
          result = Math . max ( result , count ) ;
        }
      }
      System . out . println ( result ) ;
      T -- ;
    }
  }
  catch ( Exception e ) {
    return ;
  }
}

public static void main ( String args [ ] ) { try { Scanner sc = new Scanner ( System . in ) ; int T = sc . nextInt ( ) ; System . out . println ( ) ; while ( T > 0 ) { int A [ ] = new int [ T ] ; for ( int i = 0 ; i < T ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int B [ ] = new int [ 2 * T ] ; for ( int i = 0 ; i < T ; i ++ ) { B [ i ] = A [ i ] ; } for ( int i = T ; i < 2 * T ; i ++ ) { B [ i ] = A [ i - T ] ; } int count = 0 ; int result = 0 ; for ( int i = 0 ; i < 2 * T ; i ++ ) { if ( B [ i ] == 0 ) { count = 0 ; } else { count ++ ; result = Math . max ( result , count ) ; } } System . out . println ( result ) ; T -- ; } } catch ( Exception e ) { return ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (try_statement body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (decimal_integer_literal) right: (identifier)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (identifier))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) alternative: (block (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (update_expression (identifier)))))) (catch_clause (catch_formal_parameter (catch_type (type_identifier)) name: (identifier)) body: (block (return_statement))))))