#include<iostream>
#define Max 1000001
using namespace std;

int n;
int euler[Max];
long long ans[Max];

int main(){
  for(int i=0;i<Max;i++)euler[i] = i;
  for(int i=2;i<Max;i++){
    if(euler[i] == i){
      for(int j=i;j<Max;j+=i)euler[j] = euler[j] / i *(i-1);
    }
  }

  ans[1] = 0;
  for(int i=2;i<Max;i++)ans[i] = ans[i-1] + euler[i];

  int t;
  cin >> t;
  for(int i=0;i<t;i++){
    cin >> n;
    cout << ans[n] + 2 << endl;
  }
}