use proconio::input; fn main() { input! { t: usize, ns: [u64; t], } for mut n in ns { let mut cur = 0; let mut ans = 0u64; let m = n + 1; while n > 0 { let p = 2u64.pow(cur); let add = (m / (p * 2)) * p + ((m / p) % 2) * (m % p); ans += add; n /= 2; cur += 1; } println!("{ans}"); } }