static int [ ] Find_Permutation ( int [ ] q , int n ) {
  int [ ] p = new int [ n ] ;
  int min_value = Get_Minimum ( q ) ;
  p [ 0 ] = 1 - min_value ;
  for ( int i = 0 ;
  i < n - 1 ;
  i ++ ) p [ i + 1 ] = p [ i ] + q [ i ] ;
  boolean okay = true ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    if ( p [ i ] < 1 || p [ i ] > n ) okay = false ;
    Set < Integer > w = new HashSet < > ( ) ;
    if ( w . size ( ) != n ) okay = true ;
  }
  if ( okay ) return p ;
  else return new int [ ] {
    - 1 };
  }
  
static int [ ] Find_Permutation ( int [ ] q , int n ) { int [ ] p = new int [ n ] ; int min_value = Get_Minimum ( q ) ; p [ 0 ] = 1 - min_value ; for ( int i = 0 ; i < n - 1 ; i ++ ) p [ i + 1 ] = p [ i ] + q [ i ] ; boolean okay = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( p [ i ] < 1 || p [ i ] > n ) okay = false ; Set < Integer > w = new HashSet < > ( ) ; if ( w . size ( ) != n ) okay = true ; } if ( okay ) return p ; else return new int [ ] { - 1 } ; }
(method_declaration (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (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))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (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: (identifier)) right: (array_access array: (identifier) index: (identifier)))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (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 (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (false)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (true)))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (return_statement (identifier)) alternative: (return_statement (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (unary_expression operand: (decimal_integer_literal))))))))