static long solve ( Long [ ] arr , int n ) {
  Arrays . sort ( arr ) ;
  long reng = ( long ) 1e15 ;
  long ans = ( long ) 1e15 ;
  boolean finished = false ;
  for ( long C = 1 ;
  ;
  C ++ ) {
    long res = 0 ;
    for ( long i = 0 , pw = 1 ;
    i < n ;
    i ++ , pw *= C ) {
      if ( pw >= reng ) {
        finished = true ;
        break ;
      }
      res += Math . abs ( ( arr [ ( int ) i ] - pw ) ) ;
    }
    if ( finished ) break ;
    ans = Math . min ( ans , res ) ;
  }
  return ans ;
}

static long solve ( Long [ ] arr , int n ) { Arrays . sort ( arr ) ; long reng = ( long ) 1e15 ; long ans = ( long ) 1e15 ; boolean finished = false ; for ( long C = 1 ; ; C ++ ) { long res = 0 ; for ( long i = 0 , pw = 1 ; i < n ; i ++ , pw *= C ) { if ( pw >= reng ) { finished = true ; break ; } res += Math . abs ( ( arr [ ( int ) i ] - pw ) ) ; } if ( finished ) break ; ans = Math . min ( ans , res ) ; } return ans ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (decimal_floating_point_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (decimal_floating_point_literal)))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (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: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) update: (assignment_expression left: (identifier) right: (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (true))) (break_statement))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (cast_expression type: (integral_type) value: (identifier))) right: (identifier))))))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (break_statement)) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (return_statement (identifier))))