n=int(input()) A=list(map(int,input().split())) for i in range(2*n-3): for p in range(n)[::-1]: q=i-p if n-1A[q]:A[p],A[q]=A[q],A[p] print(*A)