import java.math.BigInteger;

public class Euler320 {
    static final long K = 1234567890L;
    static final long OUTPUT_MOD = 1000000000000000000L;

    static long valuationFactorial(long n, int p) {
        long sum = 0;
        long prime = p;
        while (n > 0) {
            n /= prime;
            sum += n;
        }
        return sum;
    }

    static long minimalNForTarget(int p, long target, long previous) {
        if (target == 0)
            return 0;

        long factor = p - 1;
        long lower = Math.max(previous, target * factor);

        long hi = lower;
        while (true) {
            long have = valuationFactorial(hi, p);
            if (have >= target) {
                break;
            }
            hi += (target - have) * factor;
        }

        long lo = lower;
        while (lo < hi) {
            long mid = lo + (hi - lo) / 2;
            if (valuationFactorial(mid, p) >= target) {
                hi = mid;
            } else {
                lo = mid + 1;
            }
        }
        return lo;
    }

    static int[] buildSpf(int limit) {
        int[] spf = new int[limit + 1];
        for (int i = 0; i <= limit; i++)
            spf[i] = i;
        for (int i = 2; i * i <= limit; ++i) {
            if (spf[i] == i) {
                for (int j = i * i; j <= limit; j += i) {
                    if (spf[j] == j)
                        spf[j] = i;
                }
            }
        }
        return spf;
    }

    public static String solve() {
        int upper = 1000000;
        int[] spf = buildSpf(upper);

        long[] required = new long[upper + 1];
        long[] neededN = new long[upper + 1];

        long currentMax = 0;
        BigInteger sum = BigInteger.ZERO;

        for (int i = 2; i <= upper; ++i) {
            int x = i;
            while (x > 1) {
                int p = spf[x];
                int exp = 0;
                while (x % p == 0) {
                    x /= p;
                    ++exp;
                }
                required[p] += K * exp;
                long updated = minimalNForTarget(p, required[p], neededN[p]);
                neededN[p] = updated;
                if (updated > currentMax) {
                    currentMax = updated;
                }
            }
            if (i >= 10) {
                sum = sum.add(BigInteger.valueOf(currentMax));
            }
        }

        BigInteger outMod = BigInteger.valueOf(1000000000000000000L);
        return String.valueOf(sum.mod(outMod).longValue());
    }

    public static void main(String[] args) {
        System.out.println(solve());
    }
}
