def run_program(program: list) -> int:
    """Execute an Intcode program

    :param program: Intcode program
    :return: Output of the Intcode program
    """
    for i in range(len(program) // 4 + 1):
        opcode = program[4 * i]
        if opcode == 99:
            break
        pos1, pos2, pos3 = program[(4 * i + 1):(4 * i + 4)]
        if opcode == 1:
            program[pos3] = program[pos1] + program[pos2]
        elif opcode == 2:
            program[pos3] = program[pos1] * program[pos2]
        else:
            raise ValueError('Invalid opcode!')
    return program[0]