Traverse the array
for i in range ( 1 , N ) : NEW_LINE INDENT sum [ i ] += sum [ i - 1 ] NEW_LINE DEDENT for l in range ( 1 , N - 3 ) : NEW_LINE INDENT for r in range ( l + 2 , N - 1 ) : NEW_LINE DEDENT