static int getSteps ( int arr [ ] , int n ) {
  int count = 0 ;
  int modulus [ ] = new int [ 4 ] ;
  int sum = 0 ;
  int i ;
  for ( i = 0 ;
  i < n ;
  i ++ ) {
    int mod = arr [ i ] % 4 ;
    sum += mod ;
    modulus [ mod ] ++ ;
  }
  if ( sum % 4 != 0 ) {
    return - 1 ;
  }
  else {
    if ( modulus [ 1 ] > modulus [ 3 ] ) {
      count += modulus [ 3 ] ;
    }
    else {
      count += modulus [ 1 ] ;
    }
    modulus [ 1 ] -= count ;
    modulus [ 3 ] -= count ;
    modulus [ 2 ] += modulus [ 1 ] / 2 ;
    modulus [ 2 ] += modulus [ 3 ] / 2 ;
    count += modulus [ 1 ] / 2 ;
    count += modulus [ 3 ] / 2 ;
    count += modulus [ 2 ] / 2 ;
    return count ;
  }
}

static int getSteps ( int arr [ ] , int n ) { int count = 0 ; int modulus [ ] = new int [ 4 ] ; int sum = 0 ; int i ; for ( i = 0 ; i < n ; i ++ ) { int mod = arr [ i ] % 4 ; sum += mod ; modulus [ mod ] ++ ; } if ( sum % 4 != 0 ) { return - 1 ; } else { if ( modulus [ 1 ] > modulus [ 3 ] ) { count += modulus [ 3 ] ; } else { count += modulus [ 1 ] ; } modulus [ 1 ] -= count ; modulus [ 3 ] -= count ; modulus [ 2 ] += modulus [ 1 ] / 2 ; modulus [ 2 ] += modulus [ 3 ] / 2 ; count += modulus [ 1 ] / 2 ; count += modulus [ 3 ] / 2 ; count += modulus [ 2 ] / 2 ; return count ; } }
(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 (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) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (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))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (return_statement (unary_expression operand: (decimal_integer_literal)))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)))) (return_statement (identifier))))))