import java.util.HashMap;
import java.util.Map;

public class Euler512 {

    static Map<Integer, Long> memo = new HashMap<>();

    static long oddNumbersSum(long x) {
        long m = (x + 1) / 2;
        return m * m;
    }

    static long oddPartPrefixSum(long n) {
        long total = 0;
        long x = n;
        while (x > 0) {
            total += oddNumbersSum(x);
            x /= 2;
        }
        return total;
    }

    static long getSum(int n) {
        if (n == 0) {
            return 0;
        }
        if (memo.containsKey(n)) {
            return memo.get(n);
        }

        long result = oddPartPrefixSum(n);
        int l = 2;
        while (l <= n) {
            int q = n / l;
            int r = n / q;
            result -= (long) (r - l + 1) * getSum(q);
            l = r + 1;
        }

        memo.put(n, result);
        return result;
    }

    public static void main(String[] args) {
        int n = 500000000;
        long ans = getSum(n);
        System.out.println(ans);
    }
}
