Problem: Golu wants to find out the sum of Lucky numbers.Lucky numbers are those numbers which contain exactly two set bits.This task is very diffcult for him.So Help Golu to find sum of those numbers which exactly contain two set bits upto a given number N.

3 5 10 are lucky numbers where 7 14 are not.

INPUT First line contain number of test cases T.Each test case contains a single number N.
OUTPUT Print sum of all Lucky Numbers upto N.Output may be large so take modulo with 1000000007.  
Constraints 

1 ≤ T ≤ 10^5
1 ≤ N ≤ 10^18

NOTE: Since value of test cases and n is really large, please use fast I/O optimization techniques. 

SAMPLE INPUT
1
5

SAMPLE OUTPUT
8

Solution (in PYTHON):

Solution:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t = int(raw_input())

N_ls = list()
ind_ls = list()
ind = 0

for tc in xrange(t):
    ind_ls.append(ind)
    N_ls.append(int(raw_input()))
    ind += 1
    
N_ind_ls = sorted(zip(N_ls, ind_ls))
sum_val_ls = list()

sum_val = 0
N_old = 1
i = 2
i_old = 2
j = 1
j_old = 1

shorted = False
ind_ls = list()

for N, indx in N_ind_ls:
    
    if N_old != N:
        
        while i < N:
            
            if shorted:
                i = i_old
                j = j_old
            else:
                j = 1
            
            while j < i:            
                
                if (i + j) <= N:
                    #print 'sum_val {} + i {} + j {}'.format(sum_val, i , j)
                    sum_val = (sum_val % 1000000007) + (i + j)
                    shorted = False
                else:
                    shorted = True
                    j_old = j
                    i_old = i
                    #print 'shorted sum_val {} + i_old {} + j_old {}'.format(sum_val, i_old , j_old)
                
                if shorted:
                    break
                else:
                    j *= 2
                    
            if shorted:
                break
            else:
                i *= 2
            
        ind_ls.append(indx)
        sum_val_ls.append(sum_val)
        
        N_old = N
        
    else:
        ind_ls.append(indx)
        sum_val_ls.append(sum_val)
        
N_ind_ls = sorted(zip(ind_ls, sum_val_ls))
    
for indx, sum_val in N_ind_ls:
    print sum_val % 1000000007