#![allow(unused_imports)] #![allow(non_snake_case)] use std::cmp::*; use std::collections::*; use std::io::Write; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let t = read::(); let mut ns = vec![]; for _ in 0..t { let n = read::(); ns.push(n); } for n in ns { let mut ans = n * n; // 1 ans += (n - 1) * n; for p in 2..31i64 { let mut i = 1i64; while i.pow(p as u32) <= n { i += 1; } let inc = (i - 2) * (n + 1 - p) * 2; if n == 5 { debug!(i, p, inc); } ans += (i - 2) * (n / p) * 2; } println!("{}", ans); } } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() }