use proconio::input; fn main() { input! { t:usize, n:[usize;t], } const D: usize = 40; for mut n in n { let mut ans = 0; n += 1; for i in 1..=D { ans += n / (1 << i) * (1 << (i - 1)) + (n % (1 << i)).saturating_sub(1 << (i - 1)); } println!("{}", ans); } }