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:
'''input
1
5
'''

#~~~~~~~~~~~~~~~~~~~~dwij28 == Abhinav Jha~~~~~~~~~~~~~~~~~~~~#

from sys import stdin, stdout
from math import sqrt, floor, ceil, log
from collections import defaultdict, Counter
from bisect import bisect_left

def read(): return stdin.readline().strip()
def write(x): stdout.write(str(x))
def endl(): write("\n")

def pre():
	data, mod = [], int(1e9)+7
	for i in xrange(64):
		for j in xrange(i+1, 64):
			x = ['0']*64
			x[i], x[j] = '1', '1'
			data.append(int(''.join(x), 2))
	data, s, x = sorted(data), [], 0 # s contains prefix sum (modulo)
	for i in data:
		x = (x + i) % mod
		s.append(x)
	return data, s

data, s = pre()
for T in xrange(int(read())):
	n = int(read())
	p = bisect_left(data, n)
	ans = s[p] if data[p] == n else s[p-1]
	write(ans if n > 2 else 0)
	endl()