k = int(input())

total = 0

def gcd(a, b):
    if b == 0:
        return a
    else:
        q, r = divmod(a, b)
        return gcd(q, r)

for i in range(1, k+1):
    for j in range(1, k+1):
        total += gcd(i, j)
print(total*k+1)
