start = 1583
stop = 1697

Q = [None,]

Q.append(1)
Q.append(1)

for n in range(3,stop+1):
    Q.append(Q[n-Q[n-1]]+Q[n-Q[n-2]])

sum_Q = 0
for n in range(start, stop+1):
    sum_Q = sum_Q + Q[n]

print(sum_Q)