import itertools

import math



n = int(eval(input()))

c1 = list(range(1, n + 1))

c2 = itertools.combinations(list(range(1, n + 1)), 2)

c3 = itertools.combinations(list(range(1, n + 1)), 3)



t1 = sum(list(c1))

t2 = sum(list([math.gcd(x[0], x[1]) for x in c2])) * 6

t3 = sum(list([math.gcd(x[0], math.gcd(x[1], x[2])) for x in c3])) * 6



print((sum([t1, t2, t3])))

k, = (int(x) for x in input().split())

 

n = 3

c = {} 

t = 0

for x in range(k, 0, -1):

    c[x] = (k // x) ** n

    c[x] = c[x] - sum(c[x * y] for y in range(2, k // x + 1))

    s = c[x] * x

    t += s

    # t = t % 1000000007

 

print(t)
import itertools
import math

n = int(eval(input()))
c1 = list(range(1, n + 1))
c2 = itertools.combinations(list(range(1, n + 1)), 2)
c3 = itertools.combinations(list(range(1, n + 1)), 3)
t1 = sum(list(c1))
t2 = sum(list([math.gcd(x[0], x[1]) for x in c2])) * 6
t3 = sum(list([math.gcd(x[0], math.gcd(x[1], x[2])) for x in c3])) * 6
print((sum([t1, t2, t3])))

(k,) = (int(x) for x in input().split())
n = 3
c = {}
t = 0
for x in range(k, 0, -1):
    c[x] = (k // x) ** n
    c[x] = c[x] - sum(c[x * y] for y in range(2, k // x + 1))
    s = c[x] * x
    t += s
    # t = t % 1000000007
print(t)

-import itertools -import math - -n = int(eval(input())) -c1 = list(range(1, n + 1)) -c2 = itertools.combinations(list(range(1, n + 1)), 2) -c3 = itertools.combinations(list(range(1, n + 1)), 3) -t1 = sum(list(c1)) -t2 = sum(list([math.gcd(x[0], x[1]) for x in c2])) * 6 -t3 = sum(list([math.gcd(x[0], math.gcd(x[1], x[2])) for x in c3])) * 6 -print((sum([t1, t2, t3]))) +(k,) = (int(x) for x in input().split()) +n = 3 +c = {} +t = 0 +for x in range(k, 0, -1): +    c[x] = (k // x) ** n +    c[x] = c[x] - sum(c[x * y] for y in range(2, k // x + 1)) +    s = c[x] * x +    t += s +    # t = t % 1000000007 +print(t)