Buggy python submission (verdict: Runtime Error):
inp=input().split()
for k in range(N):
  x.append(int(inp[k]))
def rec(x,y):
  if len(x)==1:
    for k in range(len(y)):
      print(y[k])
    return y
  OK=False
  for i in range(len(x)-1,0,-1):
    if x[i]==i:
      del x[i]
      y.insert(0,i)
      rec(x,y)
      OK=True
      break
  if OK==False:
    print(-1)
    return -1
rec(x,[])  

Fixed submission:
N=int(input())
x=[0]
inp=input().split()
for k in range(N):
  x.append(int(inp[k]))
y=[]
OK=True
for k in range(N):
  ok=False
  for i in range(len(x)-1,0,-1):
    if x[i]==i:
      y.insert(0,i)
      del x[i]
      ok=True
      break
  if ok==False:
    print(-1)
    OK=False
    break
if OK==True:
  for k in range(len(y)):
    print(y[k])

Buggy python submission (verdict: Runtime Error):
N=int(input())
r=[0]
inp=input().split()
for k in range(N):
  r.append(int(inp[k]))
def rec(x,y,i,N):
    if len(x)==1:
        for k in range(len(y)):
            print(y[k])
        return(y)
    if i==N+1:
        if len(y)==0:
            print(-1)
            return -1
        else:
            m=y[0]
            del y[0]
            x.insert(m,m)
            rec(x,y,m+1,N)     
    if x[i]==i:
        x.pop(i)
        y.insert(0,i)
        rec(x,y,1,N)
        
    else:
        if x[i] < i:
            rec(x,y,i+1,N)
        else:
            if len(y)>0:
                m=y[0]
                del y[0]
                x.insert(m,m)
                rec(x,y,m+1,N)  
            else:
                print(-1)
                return -1
                
                
            
        
    
rec(r,[],1,N)      
  

Fixed submission:
N=int(input())
x=[0]
inp=input().split()
for k in range(N):
  x.append(int(inp[k]))
y=[]
OK=True
for k in range(N):
  ok=False
  for i in range(len(x)-1,0,-1):
    if x[i]==i:
      y.insert(0,i)
      del x[i]
      ok=True
      break
  if ok==False:
    print(-1)
    OK=False
    break
if OK==True:
  for k in range(len(y)):
    print(y[k])

Buggy python submission (verdict: Runtime Error):
N=int(input())
r=[0]
inp=input().split()
for k in range(N):
  r.append(int(inp[k]))
def rec(x,y,i,N):
    if len(x)==1:
        for k in range(len(y)):
            print(y[k])
        return(y)
    if i==N+1:
        if len(y)==0:
            print(-1)
            return -1
        else:
            m=y[0]
            del y[0]
            x.insert(m,m)
            rec(x,y,m+1,N)     
    if x[i]==i:
        x.pop(i)
        y.insert(0,i)
        rec(x,y,1,N)
        
    else:
        if x[i] < i:
            rec(x,y,i+1,N)
        else:
            if len(y)>0:
                m=y[0]
                del y[0]
                x.insert(m,m)
                rec(x,y,m+1,N)  
            else:
                print(-1)
                return -1
                
                
            
        
            
        
    
rec(r,[],1,3)      
  

Fixed submission:
N=int(input())
x=[0]
inp=input().split()
for k in range(N):
  x.append(int(inp[k]))
y=[]
OK=True
for k in range(N):
  ok=False
  for i in range(len(x)-1,0,-1):
    if x[i]==i:
      y.insert(0,i)
      del x[i]
      ok=True
      break
  if ok==False:
    print(-1)
    OK=False
    break
if OK==True:
  for k in range(len(y)):
    print(y[k])