using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var ans = new long[t]; for (var u = 0; u < t; ++u) { var n = long.Parse(ReadLine()); ++n; for (var i = 0; i < 40; ++i) { var b = 2L << i; ans[u] += n - b / 2 * (n / b) - Math.Min(n % b, b / 2); } } WriteLine(string.Join("\n", ans)); } }