# Leonhard Euler was born on 15 April 1707.
# Consider the sequence 1504170715041707n mod 4503599627370517.
# An element of this sequence is defined to be an Eulercoin if it is strictly smaller than all previously found Eulercoins.
# For example, the first term is 1504170715041707 which is the first Eulercoin. 
# The second term is 3008341430083414 which is greater than 1504170715041707 so is not an Eulercoin. 
# However, the third term is 8912517754604 which is small enough to be a new Eulercoin.
# The sum of the first 2 Eulercoins is therefore 1513083232796311.
# Find the sum of all Eulercoins.

result = 0
compare = 1504170715041707
modulo = 4503599627370517
max = 1504170715041707

loop = True
i = 0

while loop: 
	number = compare + max
	number %= modulo
	if number > max:
		max = number
	if number <= compare:
		compare = number
		result += number
		print('nummer: ', number, ' eulercoin: ', result)
	if number == 1:
		loop = False

print(result+1504170715041707)