#include <iostream>

#define N 1000000

using namespace std;

typedef long long int BigInt;

BigInt phi(int n) {
    int m = n;
    BigInt retval = 1;
    for (int p=2; p*p <= m; p++) {
        int count = 0;
        while (m%p == 0) {
            count++;
            m /= p;
        }
        if (count > 0) {
            retval *= p-1;
            for (int i=0; i<count-1; i++) {
                retval *= p;
            }
        }
    }
    if (m > 1) {
        retval *= m-1;
    }
    return retval;
}

int main() {
    int t;
    int n[10000];
    BigInt f[N+1];
    cin >> t;
    for (int i=0; i<t; i++) {
        cin >> n[i];
    }
    f[1] = 2;
    for (int i=2; i<=N; i++) {
        f[i] = f[i-1]+phi(i);
    }
    for (int i=0; i<t; i++) {
        cout << f[n[i]] << endl;
    }
    return 0;
}