import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class Euler496 {

    static class Pair {
        long d;
        long mu;

        Pair(long d, long mu) {
            this.d = d;
            this.mu = mu;
        }
    }

    private static BigInteger triU128(long n) {
        BigInteger bn = BigInteger.valueOf(n);
        return bn.multiply(bn.add(BigInteger.ONE)).divide(BigInteger.valueOf(2));
    }

    private static int[] buildSpf(int n) {
        int[] spf = new int[n + 1];
        for (int i = 2; i <= n; ++i) {
            if (spf[i] == 0) {
                spf[i] = i;
                if ((long) i * i <= n) {
                    for (int x = i * i; x <= n; x += i) {
                        if (spf[x] == 0)
                            spf[x] = i;
                    }
                }
            }
        }
        if (n >= 1)
            spf[1] = 1;
        return spf;
    }

    private static List<List<Pair>> buildSquarefreeMuDivisors(int n, int[] spf) {
        List<List<Pair>> divs = new ArrayList<>(n + 1);
        for (int i = 0; i <= n; i++)
            divs.add(new ArrayList<>());
        if (n >= 1)
            divs.get(1).add(new Pair(1, 1));

        for (int x = 2; x <= n; ++x) {
            int t = x;
            List<Integer> primes = new ArrayList<>();
            while (t > 1) {
                int p = spf[t];
                primes.add(p);
                while (t % p == 0) {
                    t /= p;
                }
            }

            List<Pair> cur = new ArrayList<>();
            cur.add(new Pair(1, 1));
            for (int p : primes) {
                int before = cur.size();
                for (int i = 0; i < before; ++i) {
                    cur.add(new Pair(cur.get(i).d * p, -cur.get(i).mu));
                }
            }
            divs.set(x, cur);
        }
        return divs;
    }

    private static BigInteger coprimePrefixSum(long x, List<Pair> sqfDivsR) {
        if (x == 0)
            return BigInteger.ZERO;
        BigInteger out = BigInteger.ZERO;
        for (Pair p : sqfDivsR) {
            long q = x / p.d;
            BigInteger term = BigInteger.valueOf(p.d).multiply(triU128(q));
            if (p.mu > 0) {
                out = out.add(term);
            } else {
                out = out.subtract(term);
            }
        }
        return out;
    }

    private static BigInteger coprimeRangeSum(long l, long rr, List<Pair> sqfDivsR) {
        if (l > rr)
            return BigInteger.ZERO;
        BigInteger hi = coprimePrefixSum(rr, sqfDivsR);
        BigInteger lo = coprimePrefixSum(l - 1, sqfDivsR);
        return hi.subtract(lo);
    }

    public static void main(String[] args) {
        long L = 1000000000L;
        if (L < 2) {
            System.out.println(0);
            return;
        }

        int rMax = (int) Math.sqrt(L);
        int[] spf = buildSpf(rMax);
        List<List<Pair>> sqfDivs = buildSquarefreeMuDivisors(rMax, spf);

        BigInteger total = BigInteger.ZERO;

        for (int r = 1; r <= rMax; ++r) {
            long sLo = r + 1L;
            long sHi = Math.min(2L * r - 1L, L / r);
            if (sLo > sHi)
                continue;

            while (sLo <= sHi) {
                long m = L / (r * sLo);
                long sEnd = Math.min(sHi, L / (r * m));

                BigInteger sumS = coprimeRangeSum(sLo, sEnd, sqfDivs.get(r));
                BigInteger add = BigInteger.valueOf(r).multiply(triU128(m)).multiply(sumS);
                total = total.add(add);

                sLo = sEnd + 1L;
            }
        }

        System.out.println(total.toString());
    }
}
