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:
from sys import stdin, stdout

def bitCount(n):
	counter = 0
	while(n > 0):
		n=n>>1
		counter +=1
	return counter

def feeling_luckey(n):
	modulo = 1000000007
	sum = 0
	bitc = bitCount(n)
	
	for i in range(1,bitc-1):
		max = 1 << i
		sum += ((max *i)+(max -1))
		sum %= modulo
	
	msb = 1 << (bitc-1)
	lsb = 1
	
	while(n >= (msb+lsb)):
		sum += (msb+lsb)
		sum %= modulo

		lsb = lsb << 1
	
	return sum
	
# def feeling_luckey(n):
# 	sum = 0
# 	max = 2
# 	min = 1
# 	if n < max:
# 		return 0
# 	else:
# 		while( n >= min+max):
# 			sum += (min+max)
# 			min = min << 1
# 			# print sum,min,max
# 			if min >= max:
# 				min =1
# 				max = max << 1

# 	return sum

# tc = int(raw_input())
try:
	tc = int(stdin.readline())
	while (tc):
		# n = int(raw_input())
		n = int(stdin.readline())
		result = feeling_luckey(n)
		cnt = result%1000000007
		# print result%1000000007
		stdout.write(str(cnt)+'\n')
		tc -= 1
except Exception as e:
	print e.message