from sympy import isprime a,b=map(int,input().split()) res=0 for i in range(a,b+1): if isprime(i):res+=i**3-i*i+i+1; print(res)