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

mod = 1000000007

def ans_of_last_set_bit(a, b):
    ans1 = (int(math.pow(2, b)) - 1) % mod
    ans2 = (int(math.pow(2, a - 1)) * b) % mod
    # print ans1, ans2
    return (ans1 + ans2) % mod

t = int(raw_input())
for i in range(t):
    n = int(raw_input())
    if n == 1 or n == 2:
        print "0"
    else:
        if math.log(n, 2) == int(math.log(n, 2)):
            n -= 1
        j, last, seclast, ans = 1, -1, -1, 0
        while n:
            if n & 1 == 1:
                seclast = last
                last = j
                # print last, seclast
            n >>= 1
            j += 1
        while seclast:
            ans = (ans + ans_of_last_set_bit(last, seclast)) % mod
            last -= 1
            seclast = last - 1
        print ans