"""
Aurthor:Prathmesh Agrawal
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 , find the sum of the even-valued terms. 
"""

#!/bin/python3

import sys


t = int( input().strip() )
for a0 in range( t ):
    
	n = int( input().strip() )
    fibbo = [ 1 , 2 ]
    even = [ 2 ]
    i = 0
	
    while 1:
        
		fibbo.append(fibbo[i]+fibbo[i+1])
        
		if fibbo[i+2]%2==0:
            if fibbo[i+2]<n:
                even.append(fibbo[i+2])
            else:
                break
        
		i+=1
        
    print(sum(even))