Does the proposed O(n) algorithm work correctly? I don't believe it returns the correct result for [100, -200, -200]. Also, it's implemented in Perl. :P