from sympy.ntheory import sqrt_mod
#print(sum(max(sqrt_mod(1,n,True)) for n in range(3,2*(10**7)+1)))
s=0
for n in range(3,2*(10**7)+1):
s+=sorted(sqrt_mod(1,n,True))[-2]
if n%20000==0:
print(f"{n/200000:.1f} percent completed, current sum: {s}")
print(s)