#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int euler(int num){

	 int ret = num;

	 for(int i = 2; i*i <= num;  i++){
			if(num%i == 0) {
				  ret  = ret/i*(i-1);
				  while(num%i == 0)num /= i;
			}
	  }
	  if(num != 1) ret = ret/num*(num-1);
	  return ret;
}

int main(){

	ll* table = new ll[1000001];

	table[1] = 2;

	for(int i = 2; i <= 1000000; i++){
		table[i] = table[i-1] + euler(i);
	}

	int Q;
	scanf("%d",&Q);

	int tmp;

	for(int loop = 0; loop < Q; loop++){
		scanf("%d",&tmp);
		printf("%lld\n",table[tmp]);
	}

	return 0;
}