def merge(A: List[int], help: List[int], left: int, mid: int, right: int) -> None:
i, j, k = left, mid + 1, left
while i <= mid:
if j > right or A[i] <= A[j]:
help[k] = A[i]
i, k = i + 1, k + 1
else:
help[k] = A[j]
j, k = j + 1, k + 1
while j <= right:
help[k] = A[j]
j, k = j + 1, k + 1
A[left : right + 1] = help[left : right + 1]
def merge_sort(A: List[int], help: List[int], left: int, right: int) -> None:
if left >= right: return
mid = left + ((right - left) >> 1)
merge_sort(A, help, left, mid)
merge_sort(A, help, mid + 1, right)
merge(A, help, left, mid, right)