import java.io.BufferedReader import java.io.InputStream import java.io.InputStreamReader import java.util.* import kotlin.math.abs import kotlin.math.max import kotlin.math.min import kotlin.math.sqrt val MOD = 1_000_000_007L fun factorize(a: Int): MutableMap { val res = mutableMapOf() var x = a loop@while(x > 1) { var i = 2 while(i * i <= x) { if (x % i == 0) { res.merge(i, 1, Int::plus) x /= i continue@loop } i++ } res.merge(x, 1, Int::plus) x = 0 } return res } tailrec fun gcd(a: Int, b: Int): Int { if (a < b) return gcd(b, a) if (b == 0) return a return gcd(b, a % b) } fun gcd(A: IntArray): Int { var g = A[0] for (i in 1 until A.size) { g = gcd(g, A[i]) } return g } class Solver(stream: InputStream, private val out: java.io.PrintWriter) { fun solve() { for (i in 0 until ni()) { out.println(solve2()) } } fun solve2(): Long { val N = ni() var ans = 0L // a = c = 1 ans += N.toLong() * N // a = c = x ans += (N - 1).toLong() * N // x > rt(N) の場合はlogxN < 2 なので a = c = xのケースしか存在しない for (x in 2 .. sqrt(N.toDouble()).toInt() + 10) { // for (x in 2 .. N) { val f = factorize(x) val p = f.map { it.value } val g = gcd(p.toIntArray()) // 2 * 3^2 * 5^3 こういうのは最小だけど、 2^2 * 3^2 みたいのは 2^1 * 3^1が最小になる if (g == 1) { debug{"x:$x"} var pow = 1 var y = x.toLong() val A = mutableListOf() while(y <= N) { A += pow y *= x pow++ } for (i in 0 until A.size - 1) { for (j in i + 1 until A.size) { val a = A[i] val c = A[j] val m = max(a, c) / gcd(a, c) val cnt = N / m debug{"$a:$c m:$m cnt:$cnt"} ans += 2 * cnt } } } } return ans } private val isDebug = try { // なんか本番でエラーでる System.getenv("MY_DEBUG") != null } catch (t: Throwable) { false } private var tokenizer: StringTokenizer? = null private val reader = BufferedReader(InputStreamReader(stream), 32768) private fun next(): String { while (tokenizer == null || !tokenizer!!.hasMoreTokens()) { tokenizer = StringTokenizer(reader.readLine()) } return tokenizer!!.nextToken() } private fun ni() = next().toInt() private fun nl() = next().toLong() private fun ns() = next() private fun na(n: Int, offset: Int = 0): IntArray { return map(n) { ni() + offset } } private fun nal(n: Int, offset: Int = 0): LongArray { val res = LongArray(n) for (i in 0 until n) { res[i] = nl() + offset } return res } private fun na2(n: Int, offset: Int = 0): Array { val a = Array(2){IntArray(n)} for (i in 0 until n) { for (e in a) { e[i] = ni() + offset } } return a } private inline fun map(n: Int, f: (Int) -> Int): IntArray { val res = IntArray(n) for (i in 0 until n) { res[i] = f(i) } return res } private inline fun debug(msg: () -> String) { if (isDebug) System.err.println(msg()) } private fun debug(a: LongArray) { debug { a.joinToString(" ") } } private fun debug(a: IntArray) { debug { a.joinToString(" ") } } private fun debug(a: BooleanArray) { debug { a.map { if (it) 1 else 0 }.joinToString("") } } private fun debugDim(A: Array) { if (isDebug) { for (a in A) { debug(a) } } } /** * 勝手にimport消されるのを防ぎたい */ private fun hoge() { min(1, 2) max(1, 2) abs(-10) } } fun main() { val out = java.io.PrintWriter(System.out) Solver(System.`in`, out).solve() out.flush() }