public class Euler581 {
    static final long LIMIT_X = 10_000_000_000_000L;
    static final int[] PRIMES = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 };

    static boolean is_47_smooth(long x) {
        for (int p : PRIMES) {
            while (x % p == 0)
                x /= p;
        }
        return x == 1;
    }

    static long sum_n = 0;

    static void dfs(int idx, long cur) {
        if (idx == PRIMES.length) {
            long y_plus = 2 * cur + 1;
            long y_minus = 2 * cur - 1;
            if (is_47_smooth(y_plus))
                sum_n += 2 * cur;
            if (is_47_smooth(y_minus))
                sum_n += 2 * cur - 1;
            return;
        }
        long p = PRIMES[idx];
        long v = cur;
        while (v <= LIMIT_X) {
            dfs(idx + 1, v);
            if (v > LIMIT_X / p)
                break;
            v *= p;
        }
    }

    public static String solve() {
        sum_n = 0;
        dfs(0, 1);
        return Long.toString(sum_n);
    }

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