maxsegmenttree and sumsegmenttree