public static void solve ( ) {
  int t = in . nextInt ( ) ;
  for ( int i = 0 ;
  i < t ;
  ++ i ) {
    int n = in . nextInt ( ) ;
    long totalSum = ( ( long ) n * ( n + 1 ) ) / 2 ;
    int maxPower = 0 ;
    while ( Math . pow ( 2 , maxPower ) <= n ) {
      maxPower ++ ;
    }
    out . println ( totalSum - ( 2 * ( long ) ( Math . pow ( 2 , maxPower ) - 1 ) ) ) ;
  }
}

public static void solve ( ) { int t = in . nextInt ( ) ; for ( int i = 0 ; i < t ; ++ i ) { int n = in . nextInt ( ) ; long totalSum = ( ( long ) n * ( n + 1 ) ) / 2 ; int maxPower = 0 ; while ( Math . pow ( 2 , maxPower ) <= n ) { maxPower ++ ; } out . println ( totalSum - ( 2 * ( long ) ( Math . pow ( 2 , maxPower ) - 1 ) ) ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (cast_expression type: (integral_type) value: (identifier)) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) right: (identifier))) body: (block (expression_statement (update_expression (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) right: (decimal_integer_literal))))))))))))))