from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline # calculate φ(x) for 1 <= x <= M class euler_phi(): def __init__(self,M=10**7): *self.phi, = range(M+1) for x in range(2, M+1): if self.phi[x] == x: for y in range(x, M+1, x): self.phi[y] = self.phi[y] // x * (x-1) M = 10**7 ep = euler_phi(M) S = [0]*(M+1) S[1] = 0 for i in range(1,M): S[i+1] = S[i] + ep.phi[i+1] + (i - ep.phi[i+1])*2 def answer(): N = int(input()) print(S[N]) for _ in range(int(input())): answer()