#include<iostream>
#include<fstream>
#include<ctime>
using namespace std;
unsigned long long g(unsigned long long a,unsigned long long b)
{
if(a==0)
{
return b;
}else
{
return g(b%a,a);
}
}
int main()
{
ifstream fin("gcdsum.in");
ofstream fout("gcdsum.out");
long long n;
long long sum=0;
fin>>n;
for (int i=1;i<=n;i++)
sum+=g(i,n);
fout<<sum<<endl;
fin.close();
fout.close();
return 0;
}