n=int(input())
a=list(map(int,input().split()))
b=0
for _ in a:
    for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1]=a[i-1],a[i]
            b+=1
print(*a)
print(b) 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 b=0 b 0 for _ in a:
    for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1]=a[i-1],a[i]
            b+=1 _ a for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1]=a[i-1],a[i]
            b+=1 i range(n-1,0,-1) range n-1 n 1 0 -1 if a[i]<a[i-1]:
            a[i],a[i-1]=a[i-1],a[i]
            b+=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 b+=1 b 1 print(*a) print *a a print(b) print b b+=1 1 b n=int(input()) int(input()) n b=0 0 b a=list(map(int,input().split())) list(map(int,input().split())) a
n=int(input())
a=list(map(int,input().split()))
b=0
for _ in a:
    for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1]=a[i-1],a[i]
            b+=1
print(*a)
print(b)