Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

AND Maximum Spanning Tree

By Aashiq · Limits 1s, 256 MB

You have a weighted undirected complete graph of NN nodes numbered from 00 to N1N-1.
The weight of the edge between node AA and BB is defined as AA&BB (where & denotes bitwise AND operation).
Can you find the cost of the maximum spanning tree of this graph ?

Input

First line of input consists of a single integer TT, the number of test cases.
Each test case consists of one line. First and only line of each test case contains NN, the number of nodes.

1T101 ≤ T ≤ 10
1N21051 ≤ N ≤ 2*10^5

Output

For each test case, print one integer — cost of the maximum spanning tree of the graph.

Sample

InputOutput
4
3
6
11
8

0
8
39
21

A complete graph is a simple undirected graph in which every pair of distinct vertices is connected by a unique edge.

    Discussion

    Statistics


    0% Solution Ratio

    Submit

    Login to submit