i=input
t=int
N=t(i())
A=list(map(t,i().split()))
c=0
f = 1
while f:
    f = 0
    for j in range(1,N)[::-1]:
        if A[j]<A[j-1]:
            A[j],A[j-1]=A[j-1],A[j]
            f=1
            c+=1
print(*A)
print(c) i=input i input t=int t int N=t(i()) N t(i()) t i() i A=list(map(t,i().split())) A list(map(t,i().split())) list map(t,i().split()) map t i().split() ().split () i split c=0 c 0 f = 1 f 1 while f:
    f = 0
    for j in range(1,N)[::-1]:
        if A[j]<A[j-1]:
            A[j],A[j-1]=A[j-1],A[j]
            f=1
            c+=1 f f = 0 f 0 for j in range(1,N)[::-1]:
        if A[j]<A[j-1]:
            A[j],A[j-1]=A[j-1],A[j]
            f=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]
            f=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 f=1 f 1 c+=1 c 1 print(*A) print *A A print(c) print c c+=1 1 c t=int int t f=1 1 f c=0 0 c i=input input i A=list(map(t,i().split())) list(map(t,i().split())) A f = 0 0 f N=t(i()) t(i()) N f = 1 1 f
i=input
t=int
N=t(i())
A=list(map(t,i().split()))
c=0
f = 1
while f:
    f = 0
    for j in range(1,N)[::-1]:
        if A[j]<A[j-1]:
            A[j],A[j-1]=A[j-1],A[j]
            f=1
            c+=1
print(*A)
print(c)