import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
    public static long sumGCD(long[] arr){
        long max=0;
        for(int i=0;i<arr.length;i++)
            if(arr[i]>max) max=arr[i];
        long[] c=new long[(int)max+1];
        long[] d=new long[(int)max+1];
        long[] e=new long[(int)max+1];
        for(int i=0;i<arr.length;i++) c[(int)arr[i]]++;
        for(int i=1;i<=max;i++){
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        }
        for(int i=(int)max;i>=1;i--){
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        }
        long sum=0;
        for(int i=1;i<=max;i++) sum+=(i*e[i]);
        return sum;
    }
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        long[] arr=new long[n];
        for(int i=1;i<=n;i++) arr[i-1]=i;
        long ans=sumGCD(arr);
        System.out.println(ans);
    }
} import java.io.*; io.* java import java.lang.*; lang.* java import java.util.*; util.* java public class Main{
    public static long sumGCD(long[] arr){
        long max=0;
        for(int i=0;i<arr.length;i++)
            if(arr[i]>max) max=arr[i];
        long[] c=new long[(int)max+1];
        long[] d=new long[(int)max+1];
        long[] e=new long[(int)max+1];
        for(int i=0;i<arr.length;i++) c[(int)arr[i]]++;
        for(int i=1;i<=max;i++){
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        }
        for(int i=(int)max;i>=1;i--){
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        }
        long sum=0;
        for(int i=1;i<=max;i++) sum+=(i*e[i]);
        return sum;
    }
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        long[] arr=new long[n];
        for(int i=1;i<=n;i++) arr[i-1]=i;
        long ans=sumGCD(arr);
        System.out.println(ans);
    }
} Main public static long sumGCD(long[] arr){
        long max=0;
        for(int i=0;i<arr.length;i++)
            if(arr[i]>max) max=arr[i];
        long[] c=new long[(int)max+1];
        long[] d=new long[(int)max+1];
        long[] e=new long[(int)max+1];
        for(int i=0;i<arr.length;i++) c[(int)arr[i]]++;
        for(int i=1;i<=max;i++){
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        }
        for(int i=(int)max;i>=1;i--){
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        }
        long sum=0;
        for(int i=1;i<=max;i++) sum+=(i*e[i]);
        return sum;
    } sumGCD {
        long max=0;
        for(int i=0;i<arr.length;i++)
            if(arr[i]>max) max=arr[i];
        long[] c=new long[(int)max+1];
        long[] d=new long[(int)max+1];
        long[] e=new long[(int)max+1];
        for(int i=0;i<arr.length;i++) c[(int)arr[i]]++;
        for(int i=1;i<=max;i++){
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        }
        for(int i=(int)max;i>=1;i--){
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        }
        long sum=0;
        for(int i=1;i<=max;i++) sum+=(i*e[i]);
        return sum;
    } long max=0; max 0 for(int i=0;i<arr.length;i++)
            if(arr[i]>max) max=arr[i]; int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i if(arr[i]>max) max=arr[i]; if(arr[i]>max) max=arr[i]; arr[i]>max arr[i] arr i max max=arr[i] max arr[i] arr i long[] c=new long[(int)max+1]; c new long[(int)max+1] (int)max+1 (int)max 1 long[] d=new long[(int)max+1]; d new long[(int)max+1] (int)max+1 (int)max 1 long[] e=new long[(int)max+1]; e new long[(int)max+1] (int)max+1 (int)max 1 for(int i=0;i<arr.length;i++) c[(int)arr[i]]++; int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i c[(int)arr[i]]++; c[(int)arr[i]]++ c[(int)arr[i]] c (int)arr[i] arr i for(int i=1;i<=max;i++){
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        } int i=1; int i=1; i 1 i<=max i max i++ i++ i {
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        } {
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        } for(int j=i;j<=max;j+=i) d[i]+=c[j]; int j=i; int j=i; j i j<=max j max j+=i j+=i j i d[i]+=c[j]; d[i]+=c[j] d[i] d i c[j] c j for(int i=(int)max;i>=1;i--){
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        } int i=(int)max; int i=(int)max; i (int)max i>=1 i 1 i-- i-- i {
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        } {
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        } e[i] = d[i]*d[i]*d[i] e[i] e i d[i]*d[i]*d[i] d[i]*d[i]*d[i] d[i] d i d[i] d i d[i] d i for(int j=2*i;j<=max;j+=i) e[i] -= e[j]; int j=2*i; int j=2*i; j 2*i 2 i j<=max j max j+=i j+=i j i e[i] -= e[j]; e[i] -= e[j] e[i] e i e[j] e j long sum=0; sum 0 for(int i=1;i<=max;i++) sum+=(i*e[i]); int i=1; int i=1; i 1 i<=max i max i++ i++ i sum+=(i*e[i]); sum+=(i*e[i]) sum (i*e[i]) i e[i] e i return sum; sum long[] arr arr public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        long[] arr=new long[n];
        for(int i=1;i<=n;i++) arr[i-1]=i;
        long ans=sumGCD(arr);
        System.out.println(ans);
    } main {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        long[] arr=new long[n];
        for(int i=1;i<=n;i++) arr[i-1]=i;
        long ans=sumGCD(arr);
        System.out.println(ans);
    } BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n=Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br long[] arr=new long[n]; arr new long[n] n for(int i=1;i<=n;i++) arr[i-1]=i; int i=1; int i=1; i 1 i<=n i n i++ i++ i arr[i-1]=i; arr[i-1]=i arr[i-1] arr i-1 i 1 i long ans=sumGCD(arr); ans sumGCD(arr) sumGCD arr System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
    public static long sumGCD(long[] arr){
        long max=0;
        for(int i=0;i<arr.length;i++)
            if(arr[i]>max) max=arr[i];
        long[] c=new long[(int)max+1];
        long[] d=new long[(int)max+1];
        long[] e=new long[(int)max+1];
        for(int i=0;i<arr.length;i++) c[(int)arr[i]]++;
        for(int i=1;i<=max;i++){
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        }
        for(int i=(int)max;i>=1;i--){
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        }
        long sum=0;
        for(int i=1;i<=max;i++) sum+=(i*e[i]);
        return sum;
    }
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        long[] arr=new long[n];
        for(int i=1;i<=n;i++) arr[i-1]=i;
        long ans=sumGCD(arr);
        System.out.println(ans);
    }
} public class Main{
    public static long sumGCD(long[] arr){
        long max=0;
        for(int i=0;i<arr.length;i++)
            if(arr[i]>max) max=arr[i];
        long[] c=new long[(int)max+1];
        long[] d=new long[(int)max+1];
        long[] e=new long[(int)max+1];
        for(int i=0;i<arr.length;i++) c[(int)arr[i]]++;
        for(int i=1;i<=max;i++){
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        }
        for(int i=(int)max;i>=1;i--){
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        }
        long sum=0;
        for(int i=1;i<=max;i++) sum+=(i*e[i]);
        return sum;
    }
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        long[] arr=new long[n];
        for(int i=1;i<=n;i++) arr[i-1]=i;
        long ans=sumGCD(arr);
        System.out.println(ans);
    }
} Main
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
    public static long sumGCD(long[] arr){
        long max=0;
        for(int i=0;i<arr.length;i++)
            if(arr[i]>max) max=arr[i];
        long[] c=new long[(int)max+1];
        long[] d=new long[(int)max+1];
        long[] e=new long[(int)max+1];
        for(int i=0;i<arr.length;i++) c[(int)arr[i]]++;
        for(int i=1;i<=max;i++){
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        }
        for(int i=(int)max;i>=1;i--){
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        }
        long sum=0;
        for(int i=1;i<=max;i++) sum+=(i*e[i]);
        return sum;
    }
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        long[] arr=new long[n];
        for(int i=1;i<=n;i++) arr[i-1]=i;
        long ans=sumGCD(arr);
        System.out.println(ans);
    }
}