import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=0;
int c=1;
int d=1;
int e=1;
int r;
for(int i=1;i<=a;i++){
   for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
}
    d=1;
    e+=1;
}
System.out.println(b);
}
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=0;
int c=1;
int d=1;
int e=1;
int r;
for(int i=1;i<=a;i++){
   for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
}
    d=1;
    e+=1;
}
System.out.println(b);
}
} Main public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=0;
int c=1;
int d=1;
int e=1;
int r;
for(int i=1;i<=a;i++){
   for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
}
    d=1;
    e+=1;
}
System.out.println(b);
} main {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=0;
int c=1;
int d=1;
int e=1;
int r;
for(int i=1;i<=a;i++){
   for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
}
    d=1;
    e+=1;
}
System.out.println(b);
} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int a=sc.nextInt(); a sc.nextInt() sc.nextInt sc int b=0; b 0 int c=1; c 1 int d=1; d 1 int e=1; e 1 int r; r for(int i=1;i<=a;i++){
   for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
}
    d=1;
    e+=1;
} int i=1; int i=1; i 1 i<=a i a i++ i++ i {
   for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
}
    d=1;
    e+=1;
} {
   for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
}
    d=1;
    e+=1;
} for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
} int j=1; int j=1; j 1 j<=a j a j++ j++ j {
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
} {
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
} for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
} int k=1; int k=1; k 1 k<=a k a k++ k++ k {
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
} {
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
} while((r=c%d)!=0){
    c=d;
    d=r;
} (r=c%d)!=0 (r=c%d) r c%d c d 0 {
    c=d;
    d=r;
} c=d c d d=r d r while((r=d%e)!=0){
    d=e;
    e=r;
} (r=d%e)!=0 (r=d%e) r d%e d e 0 {
    d=e;
    e=r;
} d=e d e e=r e r b+=e b e c=k c k d=j d j e=i e i c+=1 c 1 c=1 c 1 d+=1 d 1 d=1 d 1 e+=1 e 1 System.out.println(b) System.out.println System.out System System.out b String[] args args public class Main {
    public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=0;
int c=1;
int d=1;
int e=1;
int r;
for(int i=1;i<=a;i++){
   for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
}
    d=1;
    e+=1;
}
System.out.println(b);
}
} public class Main {
    public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=0;
int c=1;
int d=1;
int e=1;
int r;
for(int i=1;i<=a;i++){
   for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
}
    d=1;
    e+=1;
}
System.out.println(b);
}
} Main
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=0;
int c=1;
int d=1;
int e=1;
int r;
for(int i=1;i<=a;i++){
   for(int j=1;j<=a;j++){
       for(int k=1;k<=a;k++){
while((r=c%d)!=0){
    c=d;
    d=r;
}
while((r=d%e)!=0){
    d=e;
    e=r;
}
b+=e;
c=k;
d=j;
e=i;
    c+=1;
}
       c=1;
    d+=1;
}
    d=1;
    e+=1;
}
System.out.println(b);
}
}