#include <stdio.h>

typedef long long ll;

ll pw(ll x,ll n){
    ll ans = 1;
    while(n){
        if(n&1) ans*=x;
        x*=x;
        n>>=1;
    }
    return ans;
}

int main(){
    int K;
    scanf("%d",&K);
    ll ans = 0;
    ll v[K];
    for(int i = K-1;i>=0;i--){
        v[i] = pw(K/(i+1),3LL);
        for(int j = 2*(i+1);j <= K;j+=(i+1)) v[i] -= v[j-1];
    }
    for(int i = 0;i<K;i++) ans+=(v[i]*(i+1LL));
    printf("%lld\n",ans);
    return 0;
}