static int maxEvenLenSum ( int arr [ ] , int n ) {
  if ( n < 2 ) return 0 ;
  int [ ] dp = new int [ n ] ;
  dp [ n - 1 ] = 0 ;
  dp [ n - 2 ] = arr [ n - 2 ] + arr [ n - 1 ] ;
  for ( int i = n - 3 ;
  i >= 0 ;
  i -- ) {
    dp [ i ] = arr [ i ] + arr [ i + 1 ] ;
    if ( dp [ i + 2 ] > 0 ) dp [ i ] += dp [ i + 2 ] ;
  }
  int maxSum = Arrays . stream ( dp ) . max ( ) . getAsInt ( ) ;
  return maxSum ;
}

static int maxEvenLenSum ( int arr [ ] , int n ) { if ( n < 2 ) return 0 ; int [ ] dp = new int [ n ] ; dp [ n - 1 ] = 0 ; dp [ n - 2 ] = arr [ n - 2 ] + arr [ n - 1 ] ; for ( int i = n - 3 ; i >= 0 ; i -- ) { dp [ i ] = arr [ i ] + arr [ i + 1 ] ; if ( dp [ i + 2 ] > 0 ) dp [ i ] += dp [ i + 2 ] ; } int maxSum = Arrays . stream ( dp ) . max ( ) . getAsInt ( ) ; return maxSum ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (decimal_integer_literal))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list)))) (return_statement (identifier))))