#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
long long b[1000001];
void ep(int a[]){
  int i,j;
  for(i=1;i<=1000000;++i)
    a[i]=i;
  bool b[1000001]={};

  for(i=2;i<=1000000;++i){
    if(b[i])
      continue;
    for(j=i;j<=1000000;j+=i){
      a[j]-=a[j]/i;
      b[j]=true;
    }
  }
  return;
}
int main(){
  int i;
  int a[1000001];
  ep(a);
  //long long b[1000001];
  b[1]=2;
  for(i=2;i<=1000000;++i)
    b[i]=b[i-1]+a[i];
  int n;
  scanf("%d",&n);
  for(i=0;i<n;++i){
    int p;
    scanf("%d",&p);
    printf("%lld\n",b[p]);
  }
  return 0;
}