use std::io::Read; use std::io::Write; fn gcd(a: u64, b: u64) -> u64 { if b == 0 { a } else { gcd(b, a % b) } } fn lcm(a: u64, b: u64) -> u64 { a / gcd(a, b) * b } fn run() { let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); it.next(); for s in it { let n: u64 = s.parse().unwrap(); let mut ans = n * n;// a = c = 1 if n > 1 { ans += (n - 1) * n;// a = c > 1 } let mut set = std::collections::BTreeSet::new(); // a > c > 1 for r in 2u64.. { if r.pow(2) > n { break; } for a in 2u64.. { if r.pow(a as u32) > n { break; } for c in 1u64..a { let (p, q) = (r.pow(a as u32), r.pow(c as u32)); if set.insert((p, q)) { let x = lcm(a, c); ans += 2 * (n / (x / c)); } } } } writeln!(out, "{}", ans).ok(); } } fn main() { run(); }