def build(segTree, arr, index, left, right):
if left == right:
segTree[index] = arr[left]
return
mid = left + (right - left) // 2
build(segTree, arr, index * 2, left, mid)
build(segTree, arr, index * 2 + 1, mid + 1, right)
segTree[index] = max(segTree[index * 2], segTree[index * 2 + 1])
