from typing import List
from typing import cast


def construct_permutation(inversion_sequence: List[int]) -> List[int]:
    """Given an inversion sequence, construct the permutation."""
    length = len(inversion_sequence)
    permutation = cast(List[int], [None] * len(inversion_sequence))
    for n, b in enumerate(inversion_sequence):
        idx = 0
        step = -1
        while idx < length:
            if permutation[idx] == None:
                step += 1
                if step == b:
                    break
            idx += 1
        permutation[idx] = n

    return permutation