SegmentTreeUp update of Build function