#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

int cumPhi[1024*40];
int seive[1024*40];
const int N = 1024*40;


int calcPhi(int i) {
  
  set<int> factors;
  int original = i;
  while(seive[i] != 1) {
    factors.insert(seive[i]);
    i /= seive[i];
  }

  for(set<int>::iterator iter = factors.begin(); iter != factors.end(); iter++) {
    original /= *iter;
    original *= (*iter-1);
  }
  return original;
}

void factorSeive() {
  // seive now stores a factor
  memset(seive, -1, sizeof(seive));
  seive[0] = 1;
  seive[1] = 1;
  for(int i = 2; i < N; i++) {
    if (seive[i] == -1) {
      seive[i] = i;
      for(int j = i*i; j < N; j+= i)
        seive[j] = i;
    }
  }
}

int main() {
  factorSeive();
  cumPhi[1] = 0;
  for(int i = 2; i < N; i++)
    cumPhi[i] = cumPhi[i-1] + calcPhi(i);


  int n;
  while(cin >> n && n) {
    if (n == 1) {cout << 3 << endl; continue;}
    int ret = cumPhi[n];
    ret = ret*2 + 3;
    cout << ret << endl;

  }

  return 0;

}
