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