import java.util.*;
import java.io.*;

import java.lang.*;

class gold_coins

{

public static void main(String args[])

{

Scanner I=new Scanner(System.in);

long t=I.nextLong();

while(t–>0)

{

long n=I.nextInt();

gold_coins ob =new gold_coins();

long r=ob.coins(n);

System.out.println®;

}

}

long m;

public long coins(long n)

{

if(n==0)

return 0;

else if(n<12)

return n;

else

m = Math.max(n,coins(n/2)+coins(n/3)+coins(n/4));

return m;

}

}