Traverse the array in reverse
for i in range ( N - 1 , - 1 , - 1 ) : NEW_LINE INDENT if A [ i ] + i < N : NEW_LINE INDENT Score [ i ] = A [ i ] * Score [ A [ i ] + i ] NEW_LINE DEDENT else : NEW_LINE INDENT Score [ i ] = A [ i ] NEW_LINE DEDENT DEDENT