static long solve ( int i , int j ) {
  if ( j > 0 ) return 0 ;
  if ( i == n ) {
    return j == 0 ? 1 : 0 ;
  }
  if ( memo [ i ] [ - j ] != - 1 ) {
    return memo [ i ] [ - j ] ;
  }
  memo [ i ] [ - j ] = 0 ;
  memo [ i ] [ - j ] += solve ( i + 1 , j + v [ i ] ) ;
  memo [ i ] [ - j ] += solve ( i + 1 , j ) ;
  return memo [ i ] [ - j ] ;
}

static long solve ( int i , int j ) { if ( j > 0 ) return 0 ; if ( i == n ) { return j == 0 ? 1 : 0 ; } if ( memo [ i ] [ - j ] != - 1 ) { return memo [ i ] [ - j ] ; } memo [ i ] [ - j ] = 0 ; memo [ i ] [ - j ] += solve ( i + 1 , j + v [ i ] ) ; memo [ i ] [ - j ] += solve ( i + 1 , j ) ; return memo [ i ] [ - j ] ; }
(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))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement (ternary_expression condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) consequence: (decimal_integer_literal) alternative: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (unary_expression operand: (identifier))) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (block (return_statement (array_access array: (array_access array: (identifier) index: (identifier)) index: (unary_expression operand: (identifier)))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (unary_expression operand: (identifier))) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (unary_expression operand: (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (unary_expression operand: (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))))) (return_statement (array_access array: (array_access array: (identifier) index: (identifier)) index: (unary_expression operand: (identifier))))))