fn main() { input!{ t: usize, k: [usize; t], } for i in 0..t { let mut ans = 0; // bit毎に数える for bit_keta in 0usize..60 { let multi = 1usize << bit_keta; // 0...01...1のグループ数内の1...1 let gcnt = (k[i]+1) / (multi*2) * multi; // 0...01...1の端数 let mut hasuu = (k[i]+1) % (multi*2); if hasuu <= multi { hasuu = 0; } else { hasuu -= multi; } ans += gcnt + hasuu; } println!("{}", ans); } } // const MOD17: usize = 1000000007; // const MOD93: usize = 998244353; // const INF: usize = 1 << 60; // let dx = vec![!0, 0, 1, 0]; // 上左下右 // let dy = vec![0, !0, 0, 1]; // 上左下右 // let d = vec!{(!0, 0), (0, !0), (1, 0), (0, 1)}; // 上左下右 #[allow(unused)] use proconio::{input, marker::Chars, marker::Usize1}; #[allow(unused)] use std::{ mem::swap, cmp::min, cmp::max, cmp::Reverse, collections::HashSet, collections::BTreeSet, collections::HashMap, collections::BTreeMap, collections::BinaryHeap, collections::VecDeque, iter::FromIterator, };