import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); PrintWriter pw = new PrintWriter(System.out); for (int z = 0; z < t; z++) { long n = Long.parseLong(br.readLine()) + 1; long ans = 0; long p1 = 1; long p2 = 2; for (int i = 0; i < 40; i++) { long v1 = n / p2 * p1; long v2 = n % p2; long v3 = Math.max(v2 - p1, 0); ans += v1 + v3; p1 *= 2; p2 *= 2; } pw.println(ans); } pw.flush(); br.close(); } }