f=lambda a,b,c:(b-c-1)*(4*a*a*a+6*a*a*(b+c)+2*a*(2*b*b+b*(2*c-1)+2*c*c+c+10)+b*b*b+b*b*(c-1)+b*(c*c+10)+c*c*c+c*c+10*c+24)//(-24)
g=lambda a,b,c:(2*a+1)*(b-c-1)*(b*(2*a*a+2*a+c*c+10)+2*(a*a+a+5)*c+b*b*b+b*b*(c-1)+c*c*c+c*c+24)//(-24)
n,m=10**12,10**6
print (m*(m+1)*(4*m**3+m**2+14*m+26)//15+sum(2*g(k,n//(k+1)+1,n//k) for k in range(1,m))-2*f(n,-1,1)+2*f(n,0,1)+(m+1)*(m*(2*m*(m+1)+5)+6)//6)%(10**8)