#bubble
N=int(input())
A=[int(i) for i in input().split()]
fl=1
C=0
while fl==1:
    fl=0
    for j in range(N-1):
        if A[N-1-j]<A[N-2-j]:
            t=A[N-1-j]
            A[N-1-j]=A[N-2-j]
            A[N-2-j]=t
            C+=1
            fl=1
for j in range(N):
    A[j]=str(A[j])
print(" ".join(A))
print(C) N=int(input()) N int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i A=[int(i) for i in input().split()] A [int(i) for i in input().split()] fl=1 fl 1 C=0 C 0 while fl==1:
    fl=0
    for j in range(N-1):
        if A[N-1-j]<A[N-2-j]:
            t=A[N-1-j]
            A[N-1-j]=A[N-2-j]
            A[N-2-j]=t
            C+=1
            fl=1 fl==1 fl 1 fl=0 fl 0 for j in range(N-1):
        if A[N-1-j]<A[N-2-j]:
            t=A[N-1-j]
            A[N-1-j]=A[N-2-j]
            A[N-2-j]=t
            C+=1
            fl=1 j range(N-1) range N-1 N 1 if A[N-1-j]<A[N-2-j]:
            t=A[N-1-j]
            A[N-1-j]=A[N-2-j]
            A[N-2-j]=t
            C+=1
            fl=1 A[N-1-j]<A[N-2-j] A[N-1-j] A N-1-j N-1 N 1 j A[N-2-j] A N-2-j N-2 N 2 j t=A[N-1-j] t A[N-1-j] A N-1-j N-1 N 1 j A[N-1-j]=A[N-2-j] A[N-1-j] A N-1-j N-1 N 1 j A[N-2-j] A N-2-j N-2 N 2 j A[N-2-j]=t A[N-2-j] A N-2-j N-2 N 2 j t C+=1 C 1 fl=1 fl 1 for j in range(N):
    A[j]=str(A[j]) j range(N) range N A[j]=str(A[j]) A[j] A j str(A[j]) str A[j] A j print(" ".join(A)) print " ".join(A) " ".join " " join A print(C) print C A=[int(i) for i in input().split()] [int(i) for i in input().split()] A fl=1 1 fl fl=0 0 fl C+=1 1 C N=int(input()) int(input()) N C=0 0 C fl=1 1 fl t=A[N-1-j] A[N-1-j] t
#bubble
N=int(input())
A=[int(i) for i in input().split()]
fl=1
C=0
while fl==1:
    fl=0
    for j in range(N-1):
        if A[N-1-j]<A[N-2-j]:
            t=A[N-1-j]
            A[N-1-j]=A[N-2-j]
            A[N-2-j]=t
            C+=1
            fl=1
for j in range(N):
    A[j]=str(A[j])
print(" ".join(A))
print(C)