Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def main():
    n = int(input())
    b = list(map(int, input().split()))
    s = set()
    q = deque()

    q.append([tuple(b), [0]*n, 0])
    ans = None
    while q:
        now, history, depth = q.popleft()
        if now in s:
            continue
        s.add(now)
        if len(now) == 0:
            ans = history
            break
        for i, j in enumerate(now):
            if i+1 == j:
                tmp = history[::]
                tmp[depth] = i+1
                q.appendleft([tuple(now[:i] + now[i+1:]), tmp, depth+1])
    if ans is None:
        print(-1)
    else:
        for i in ans[::-1]:
            if i == 0:
                break
            print(i)
if __name__ == "__main__":
    main()

Fixed submission:
n = int(input())
b = list(map(int, input().split()))

def check(b):
    for i in range(len(b))[::-1]:
        if i+1 == b[i]:
            return i
    return -1

ans = []
for i in range(n):
    ind = check(b)
    if ind >= 0:
        ans.append(ind+1)
        b = b[:ind] + b[ind+1:]
    else:
        print(-1)
        exit()
for i in ans[::-1]:
    print(i)

Buggy python submission (verdict: Runtime Error):
from collections import deque
def main():
    n = int(input())
    b = np.array(list(map(int, input().split())))
    s = set()
    q = deque()

    q.append([tuple(b), [0]*n, 0])
    ans = None
    while q:
        now, history, depth = q.popleft()
        if now in s:
            continue
        s.add(now)
        if len(now) == 0:
            ans = history
            break
        for i, j in enumerate(now):
            if i+1 == j:
                tmp = history[::]
                tmp[depth] = i+1
                q.appendleft([tuple(now[:i] + now[i+1:]), tmp, depth+1])
    if ans is None:
        print(-1)
    else:
        for i in ans[::-1]:
            if i == 0:
                break
            print(i)
if __name__ == "__main__":
    main()

Fixed submission:
n = int(input())
b = list(map(int, input().split()))

def check(b):
    for i in range(len(b))[::-1]:
        if i+1 == b[i]:
            return i
    return -1

ans = []
for i in range(n):
    ind = check(b)
    if ind >= 0:
        ans.append(ind+1)
        b = b[:ind] + b[ind+1:]
    else:
        print(-1)
        exit()
for i in ans[::-1]:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def main():
    n = int(input())
    b = list(map(int, input().split()))
    q = deque()

    q.append([b[::], [0]*n, 0])
    ans = None
    while q:
        now, history, depth = q.popleft()
        if len(now) == 0:
            ans = history
            break
        for i in range(len(now))[::-1]:
            if i+1 == now[i]:
                tmp = history[::]
                tmp[depth] = i+1
                q.appendleft([[now[k] for k in range(len(now)) if k != i], tmp, depth+1])
    if ans is None:
        print(-1)
    else:
        for i in ans[::-1]:
            if i == 0:
                break
            print(i)
if __name__ == "__main__":
    main()

Fixed submission:
n = int(input())
b = list(map(int, input().split()))

def check(b):
    for i in range(len(b))[::-1]:
        if i+1 == b[i]:
            return i
    return -1

ans = []
for i in range(n):
    ind = check(b)
    if ind >= 0:
        ans.append(ind+1)
        b = b[:ind] + b[ind+1:]
    else:
        print(-1)
        exit()
for i in ans[::-1]:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def main():
    n = int(input())
    b = list(map(int, input().split()))
    q = deque()
    q.append([b[::], [0]*n, 0])
    ans = None
    while q:
        now, history, depth = q.popleft()
        if len(now) == 0:
            ans = history
            break
        for i, j in enumerate(now):
            if i+1 == j:
                tmp = history[::]
                tmp[depth] = i+1
                q.appendleft([[now[k] for k in range(len(now)) if k != i], tmp, depth+1])
    if ans is None:
        print(-1)
    else:
        for i in ans[::-1]:
            if i == 0:
                break
            print(i)
if __name__ == "__main__":
    main()

Fixed submission:
n = int(input())
b = list(map(int, input().split()))

def check(b):
    for i in range(len(b))[::-1]:
        if i+1 == b[i]:
            return i
    return -1

ans = []
for i in range(n):
    ind = check(b)
    if ind >= 0:
        ans.append(ind+1)
        b = b[:ind] + b[ind+1:]
    else:
        print(-1)
        exit()
for i in ans[::-1]:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n = int(input())
b = list(map(int, input().split()))
q = deque()
q.append([b[::], []])
ans = None
while q:
    now, history = q.popleft()
    if len(now) == 0:
        ans = history
        break
    for i, j in enumerate(now):
        if i+1 == j:
            q.appendleft([now[:i] + now[i+1:], history + [i+1]])
if ans is None:
    print(-1)
else:
    for i in ans[::-1]:
        print(i)

Fixed submission:
n = int(input())
b = list(map(int, input().split()))

def check(b):
    for i in range(len(b))[::-1]:
        if i+1 == b[i]:
            return i
    return -1

ans = []
for i in range(n):
    ind = check(b)
    if ind >= 0:
        ans.append(ind+1)
        b = b[:ind] + b[ind+1:]
    else:
        print(-1)
        exit()
for i in ans[::-1]:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n = int(input())
b = list(map(int, input().split()))
q = deque()
q.append([b[::], []])
ans = None
while q:
    now, history = q.popleft()
    if len(now) == 0:
        ans = history
        break
    for i, j in enumerate(now):
        if i+1 == j:
            q.append([now[:i] + now[i+1:], history + [i+1]])
if ans is None:
    print(-1)
else:
    for i in ans[::-1]:
        print(i)

Fixed submission:
n = int(input())
b = list(map(int, input().split()))

def check(b):
    for i in range(len(b))[::-1]:
        if i+1 == b[i]:
            return i
    return -1

ans = []
for i in range(n):
    ind = check(b)
    if ind >= 0:
        ans.append(ind+1)
        b = b[:ind] + b[ind+1:]
    else:
        print(-1)
        exit()
for i in ans[::-1]:
    print(i)