Buggy python submission (verdict: Time Limit Exceeded):
"""
A - Limited Insertion
"""
import numpy as np

N = input()
b_list = list(map(int, input().split()))
# N = 9
# b_list = [1, 1, 1, 2, 2, 1, 2, 3, 2]
# b_list = [1,1,1,2,2,1,2,3,2]
# b_list = [1,1,3,1,2]
# b_list = [2,2]


def make_idx(tmp_list):
    idx_list = np.arange(1, len(tmp_list)+1, 1)[::-1]
    return idx_list

b_list = b_list[::-1]
idx_list = make_idx(b_list)
rm_list = []

while len(b_list):
    for idx, b in zip(idx_list, b_list):
        if idx==b:
            b_list = b_list[::-1]
            b_list.remove(b)
            rm_list.append(b)
            b_list = b_list[::-1]
            break
        elif idx-b<0:
            print(-1)
#             exit()
    idx_list = make_idx(b_list)
    
for r in rm_list[::-1]:
    print(r)

Fixed submission:
"""
A - Limited Insertion
"""
import numpy as np

N = input()
b_list = list(map(int, input().split()))
# N = 9
# b_list = [1, 1, 1, 2, 2, 1, 2, 3, 2]
# b_list = [1,1,1,2,2,1,2,3,2]
# b_list = [1,1,3,1,2]
# b_list = [2,2]


def make_idx(tmp_list):
    return np.arange(1, len(tmp_list)+1, 1)[::-1]

b_list = b_list[::-1]
idx_list = make_idx(b_list)
rm_list = []

while len(b_list):
    for idx, b in zip(idx_list, b_list):
        if idx==b:
            b_list = b_list[::-1]
            b_list.remove(b)
            rm_list.append(b)
            b_list = b_list[::-1]
            break
        elif idx-b<0:
            print(-1)
            exit()
    idx_list = make_idx(b_list)
    
for r in rm_list[::-1]:
    print(r)

Buggy python submission (verdict: Runtime Error):
N = input()
b_list = list(map(int, input().split()))

# N = 3
# b_list = [1,1,3,1,2]
# b_list = [1, 1, 1, 2, 2, 1, 2, 3, 2]
# b_list = [1,1,1,2,2,1,2,3,2]

a_list = []

def insert(tmp_list, x, new):

    tmp = tmp_list[x:]
    tmp_list[x] = new
    tmp_list += tmp
    return tmp_list

p_list = []
m_list = []
z_list = []

for num, b in enumerate(b_list):
    num+=1
    
    idx = b-num
    
#     " 実現不可能 "
    if idx>0:
        print(-1)
#         exit()
    elif idx<0:
        m_list.append(b)
    elif idx==0:
        if num==1:
            continue
        z_list.append(b)

m_list.sort(reverse=True)
z_list.sort()

sol_list = []
sol_list.append(1)

m_max = max(m_list)

import numpy as np
care_dict = {}
for num, i in enumerate(n_list):
    if i!=m_max:
        continue
    d_list = []
    for j in n_list[num+1:]:
        diff = i-j
        d_list.append(diff)
    d_list = np.array(d_list)
    d_list = d_list[d_list>0]
    if len(d_list):
        care_dict[i] = len(d_list)
        
m_list = iter(m_list)
o_list = []

for m in m_list:
    
    for o in o_list:
        gr = care_dict[o]
        if len(sol_list)>= o+(gr-1):
            sol_list.append(o)
            o_list.remove(o)
    
    if m in care_dict.keys():
        gr = care_dict[m]
        
#         print(len(sol_list), m+(gr-1))
        
        if len(sol_list)>= m+(gr-1):
            sol_list.append(m)
        else:
            o_list.append(m)
    else:
        sol_list.append(m)
        
for o in o_list:
    gr = care_dict[o]
    if len(sol_list)>= o+(gr-1):
        sol_list.append(o)
        o_list.remove(o)
        
for z in z_list:
    sol_list.append(z)

for s in sol_list:        
    print(s)

Fixed submission:
"""
A - Limited Insertion
"""
import numpy as np

N = input()
b_list = list(map(int, input().split()))
# N = 9
# b_list = [1, 1, 1, 2, 2, 1, 2, 3, 2]
# b_list = [1,1,1,2,2,1,2,3,2]
# b_list = [1,1,3,1,2]
# b_list = [2,2]


def make_idx(tmp_list):
    return np.arange(1, len(tmp_list)+1, 1)[::-1]

b_list = b_list[::-1]
idx_list = make_idx(b_list)
rm_list = []

while len(b_list):
    for idx, b in zip(idx_list, b_list):
        if idx==b:
            b_list = b_list[::-1]
            b_list.remove(b)
            rm_list.append(b)
            b_list = b_list[::-1]
            break
        elif idx-b<0:
            print(-1)
            exit()
    idx_list = make_idx(b_list)
    
for r in rm_list[::-1]:
    print(r)