#include <stdio.h>

int u(int ,int);

typedef unsigned long long int ULLI;

int main()
{
    int a=1, b=1, c=1, k;
    int temp;
    ULLI sum = 0;

    scanf("%d", &k);

    while (a <= k) {
        temp= u(a, b);
        temp = u(temp, c);
        sum += temp;

        c++;
        if (c > k) {
            c = 1;
            b++;
        }
        if (b > k) {
            b = 1;
            a++;
        }
    }

    printf("%llu\n", sum);

    return 0;
}

int u(int a, int b)
{
	int r, temp;

    if (a < b) {
        temp = a;
        a = b;
        b = temp;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    
    return b;
}