'''
Each new term in the Fibonacci sequence is generated by adding the previous two terms. 
By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

By considering the terms in the Fibonacci sequence whose values do not exceed four million, 
find the sum of the even-valued terms.
'''

# Input n: the upper bound of the Fibonacci sequence  
import sys

t = int(input().strip())
for a0 in range(t):
    n = int(input().strip())
    F = [2,8]
    while (4*F[len(F)-1]+F[len(F)-2])<n:
        new = 4*F[len(F)-1]+F[len(F)-2]
        F.append(new)
        
    print(sum(F))

# Even Fibonacci numbers appear every three numbers in the Fibonacci sequence. 
# By extracting those even numbers from the sequence, a parttern F_n = 4F_(n-1) +F_(n-2) is observed, which extends the parttern of Fibonacci sequence.
# Similar to P1, the above algorithm runs faster than looping through every (even) number.
