def isPrime(n):
for x in range(2,int(n/2)+1):
if n%x == 0: return False
return True
def nextprime(n):
n+=1
while isPrime(n) == False:
n+=1
return n
maxsum = 0
primes = []
for x in {2,5,7,11,13}:
sum = 0
while sum <1000000:
sum += x
x = nextprime(x)
if isPrime(sum) and (sum > maxsum) and (sum < 1000000): maxsum = sum
print(maxsum)