ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
ans = 0


def gcd(a,b):
    dv = 2
    c = a
    while a > 1:
        if b%c==0:
            return a
        if a%dv == 0:
            c = a//dv
        dv +=1
    return 1




dp = [[0]*(n+1) for i in range(n+1)]
for i in range(1,n):
    for j in range(i+1,n+1):
        dp[i][j] = gcd(i,j)

for i in range(1,n+1):
    dp[i][i] = i




if n == 1:
    print(1)

else:
    sl = []
    for i in range(2,n+1):
        for j in range(2,i):
            if i%j == 0:
                break
        else:
            sl.append(i)
        
    for i in range(1,n+1):
        for j in range(i,n+1):
            bv = dp[i][j]
            if i == j:
                seki = 3
            else:
                seki = 6

            for k in range(j,n+1):
                if i == j == k: continue
                
                elif i==k or j == k:
                    ans += dp[bv][k] * 3
                    # ans = gcd(bv,k) * 3
                else:
                    ans += dp[bv][k] * seki
                    # ans = gcd(bv,k) * seki
                # print(i,j,k,ans)
    for i in range(1,n+1):
        ans += i

    print(ans)