import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long sum = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        }

        System.out.printf("%d\n", sum);
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long sum = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        }

        System.out.printf("%d\n", sum);
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long sum = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        }

        System.out.printf("%d\n", sum);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long sum = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        }

        System.out.printf("%d\n", sum);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long sum = 0; sum 0 for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        } {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        } for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            } int j = 1; int j = 1; j 1 j <= i j i j++ j++ j {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            } {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            } for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                } int k = 1; int k = 1; k 1 k <= j k j k++ k++ k {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                } {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                } int count = Math.max(Math.max(i, j), k); count Math.max(Math.max(i, j), k) Math.max Math Math.max(i, j) Math.max Math i j k while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    } count > 0 count 0 {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    } if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        } i == j && j == k i == j i j j == k j k {
                            sum += count;
                            break;
                        } sum += count sum count break; {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        } if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            } i % count == 0 && j % count == 0 && k % count == 0 i % count == 0 && j % count == 0 && k % count == 0 i % count == 0 i % count i count 0 j % count == 0 j % count j count 0 k % count == 0 k % count k count 0 {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            } if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                } i != j && i != k && j != k i != j && i != k && j != k i != j i j i != k i k j != k j k {
                                    sum += 6 * count;
                                } sum += 6 * count sum 6 * count 6 count {
                                    sum += 3 * count;
                                } sum += 3 * count sum 3 * count 3 count break; count-- count System.out.printf("%d\n", sum) System.out.printf System.out System System.out "%d\n" sum sc.close() sc.close sc String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long sum = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        }

        System.out.printf("%d\n", sum);
        sc.close();
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long sum = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        }

        System.out.printf("%d\n", sum);
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long sum = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        }

        System.out.printf("%d\n", sum);
        sc.close();
    }
}