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:
import math

def getLuckyNumberSum(max):
    l = []
    offset = int(math.log(max)/math.log(2)) + 1
    i = 0
    while i < offset:
        j = i + 1
        while j <= offset:
            l.append(2**i + 2**j)
            j += 1
        i += 1
    l.sort()
    d = {}
    s = 0
    for n in l:
        s += n
        d[n] = s
    #print d
    return d
    
def findNearest(k, n, ind, pos, l):
    if n < 3:
        return -1, 0
    left = 0
    right = l - 1
    if ind == -1:
        left = pos
    else:
        right = pos
    old = -1
    #print ind, pos
    while True:
        m = (left + right)/2
        #print left, right, m, k[m], n, old
        if n == k[m]:
            return k[m], m
        elif n > k[m]:
            left = m + 1
            old = k[m]
        else:
            right = m - 1
        if left >= l or right <= 0 or left > right:
            if right >= 0 and old == -1:
                old = k[m - 1]
            return old, m

n = int(raw_input())
old = 10**18 + 1
d = getLuckyNumberSum(old)
l = d.keys()
l.sort()
length = len(l)
oldPos = length - 1
#print l, d
while n > 0:
    c = int(raw_input())
    a, oldPos = findNearest(l, c, -1 if old < c else 1, oldPos, length)
    old = c
    if a < 0:
        print 0
        oldPos = 0
    else:
        print d[a] % 1000000007
    n -= 1