solved the max consecutive sum problem in linear time