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