public class Euler747 {
    static final long kMod = 1000000007L;

    static long isqrtFloor(long n) {
        if (n == 0)
            return 0;
        long r = (long) Math.sqrt(n);
        while ((r + 1) * (r + 1) <= n)
            r++;
        while (r * r > n)
            r--;
        return r;
    }

    static long isqrtCeil(long n) {
        long r = isqrtFloor(n);
        return (r * r == n) ? r : (r + 1);
    }

    static long psiPrefixExactMod(long n) {
        long ans128 = 0; // we can do mod arithmetic as we go, but be careful with negative and large
        // actually n=10^8 is small enough that intermediate terms for ans might
        // overflow long if we don't mod,
        // but n^3 / 6 for n=10^8 is ~ 10^24, which requires BigInteger or careful
        // modding.
        // Let's do careful modding.

        long term1 = (n + 18) % kMod;
        long term2 = (n - 1) % kMod;
        long term3 = (n - 2) % kMod;

        // (n+18)*(n-1)*(n-2) / 6 mod 1000000007
        // division by 6 mod kMod: 6 * inv_6 = 1 mod kMod
        long inv6 = 166666668L; // 1000000008 / 6 = 166666668

        long initAns = (term1 * term2) % kMod;
        initAns = (initAns * term3) % kMod;
        initAns = (initAns * inv6) % kMod;

        long ans = initAns;

        for (long x = 1; 4 * x * x <= n; ++x) {
            for (long y = x; 4 * x * y <= n; ++y) {
                long disc = 4 * x * y * (x + 1) * (y + 1);
                long zMin = isqrtCeil(disc) + 2 * x * y;
                long zMax = n - 1 - x - y;

                if (zMin > zMax)
                    continue;

                long cnt = 2 * (zMax - zMin + 1);
                if (zMin * zMin == 4 * (x + y + zMin + 1) * x * y) {
                    cnt--;
                }

                long mult = (x == y) ? 1 : 2;
                long addAmt = (3L * (cnt % kMod)) % kMod;
                addAmt = (addAmt * mult) % kMod;

                ans = (ans + addAmt) % kMod;
            }
        }
        return (ans % kMod + kMod) % kMod;
    }

    public static String solve() {
        return Long.toString(psiPrefixExactMod(100000000L));
    }

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