When current subarray sum becomes 0 replace it with the smallest element
for i in range ( N - 1 , - 1 , - 1 ) : NEW_LINE INDENT sum += a [ i ] NEW_LINE if ( sum == 0 ) : NEW_LINE INDENT if ( a [ i ] != a [ 0 ] ) : NEW_LINE INDENT sum -= a [ i ] NEW_LINE DEDENT DEDENT DEDENT