static int recur ( int ind , int cnt , int last , int a [ ] , int n , int k , int dp [ ] [ ] ) {
  if ( cnt == k ) return 0 ;
  if ( ind == n ) return ( int ) - 1e9 ;
  if ( dp [ ind ] [ cnt ] != - 1 ) return dp [ ind ] [ cnt ] ;
  int ans = 0 ;
  for ( int i = ind ;
  i < n ;
  i ++ ) {
    if ( cnt % 2 == 0 ) ans = Math . max ( ans , recur ( i + 1 , cnt + 1 , i , a , n , k , dp ) ) ;
    else ans = Math . max ( ans , __gcd ( a [ last ] , a [ i ] ) + recur ( i + 1 , cnt + 1 , 0 , a , n , k , dp ) ) ;
  }
  return dp [ ind ] [ cnt ] = ans ;
}

static int recur ( int ind , int cnt , int last , int a [ ] , int n , int k , int dp [ ] [ ] ) { if ( cnt == k ) return 0 ; if ( ind == n ) return ( int ) - 1e9 ; if ( dp [ ind ] [ cnt ] != - 1 ) return dp [ ind ] [ cnt ] ; int ans = 0 ; for ( int i = ind ; i < n ; i ++ ) { if ( cnt % 2 == 0 ) ans = Math . max ( ans , recur ( i + 1 , cnt + 1 , i , a , n , k , dp ) ) ; else ans = Math . max ( ans , __gcd ( a [ last ] , a [ i ] ) + recur ( i + 1 , cnt + 1 , 0 , a , n , k , dp ) ) ; } return dp [ ind ] [ cnt ] = ans ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (cast_expression type: (integral_type) value: (unary_expression operand: (decimal_floating_point_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (return_statement (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))) (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: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (identifier) (identifier) (identifier) (identifier))))))) alternative: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (array_access array: (identifier) index: (identifier)))) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal)) (decimal_integer_literal) (identifier) (identifier) (identifier) (identifier))))))))))) (return_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (identifier)))))