#![allow(non_snake_case, unused_must_use, unused_imports)] use std::io::{self, prelude::*}; fn main() { let (stdin, stdout) = (io::read_to_string(io::stdin()).unwrap(), io::stdout()); let (mut stdin, mut buffer) = (stdin.split_whitespace(), io::BufWriter::new(stdout.lock())); for _ in 0..stdin.next().unwrap().parse::().unwrap() { solve(&mut stdin, &mut buffer); } } fn solve(stdin: &mut std::str::SplitWhitespace, buffer: &mut io::BufWriter) { macro_rules! input { ($t: ty) => { stdin.next().unwrap().parse::<$t>().unwrap() }; ($t: ty, $n: expr) => { (0..$n).map(|_| input!($t)).collect::>() }; } let mut N = input!(u64); N += 1; let mut ans = 0; for i in 0..50 { ans += (N / (1 << (i + 1))) * (1 << i); if (N % (1 << (i + 1))) >= 1 << i { ans += (N % (1 << (i + 1))) - (1 << i); } } writeln!(buffer, "{}", ans); }