N=int(input())
A=list(map(int,input().split()))[::-1]
flag=1
count=0
while flag:
    flag=0
    for i in range(N-1):
        if A[i]<A[i+1]:
            A[i],A[i+1]=A[i+1],A[i]
            flag=1
            count+=1

print(*A[::-1])
print(count) N=int(input()) N int(input()) int input() input A=list(map(int,input().split()))[::-1] A list(map(int,input().split()))[::-1] (map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ::-1 -1 flag=1 flag 1 count=0 count 0 while flag:
    flag=0
    for i in range(N-1):
        if A[i]<A[i+1]:
            A[i],A[i+1]=A[i+1],A[i]
            flag=1
            count+=1 flag flag=0 flag 0 for i in range(N-1):
        if A[i]<A[i+1]:
            A[i],A[i+1]=A[i+1],A[i]
            flag=1
            count+=1 i range(N-1) range N-1 N 1 if A[i]<A[i+1]:
            A[i],A[i+1]=A[i+1],A[i]
            flag=1
            count+=1 A[i]<A[i+1] A[i] A i A[i+1] A i+1 i 1 A[i],A[i+1]=A[i+1],A[i] A[i] A i A[i+1] A i+1 i 1 A[i+1] A i+1 i 1 A[i] A i flag=1 flag 1 count+=1 count 1 print(*A[::-1]) print *A[::-1] A[::-1] A ::-1 -1 print(count) print count A=list(map(int,input().split()))[::-1] list(map(int,input().split()))[::-1] A count=0 0 count flag=1 1 flag flag=1 1 flag flag=0 0 flag N=int(input()) int(input()) N count+=1 1 count
N=int(input())
A=list(map(int,input().split()))[::-1]
flag=1
count=0
while flag:
    flag=0
    for i in range(N-1):
        if A[i]<A[i+1]:
            A[i],A[i+1]=A[i+1],A[i]
            flag=1
            count+=1

print(*A[::-1])
print(count)
