mx = 10 ** 7 pt = [0] * (mx + 1) euler = [1] * (mx + 1) for i in range(2, mx + 1): if pt[i] == 0: for j in range(i, mx + 1, i): euler[j] *= i - 1 k = j // i while k % i == 0: k //= i euler[j] *= i pt[j] = 1 for i in range(1, mx): euler[i+1] += euler[i] T = int(input()) for _ in range(T): n = int(input()) v = euler[n] - 1 print(2*(n * (n-1) // 2 - v) + v)