Iterate from 0 to n - 1
for i in range ( n ) : NEW_LINE INDENT if ( k and arr [ i ] < 0 ) : NEW_LINE INDENT arr [ i ] *= - 1 NEW_LINE k -= 1 NEW_LINE continue NEW_LINE DEDENT break NEW_LINE DEDENT if ( i == n ) : NEW_LINE INDENT i -= 1 NEW_LINE DEDENT if ( k == 0 or k % 2 == 0 ) : NEW_LINE INDENT return sumArray ( arr , n ) NEW_LINE DEDENT if ( i != 0 and abs ( arr [ i ] ) >= abs ( arr [ i - 1 ] ) ) : NEW_LINE INDENT i -= 1 NEW_LINE DEDENT arr [ i ] *= - 1 NEW_LINE return sumArray ( arr , n ) NEW_LINE