n=int(input())
a=[int(i) for i in input().split(" ")]
x=0
flg=1
while flg:
    flg=0
    for i in range(n-1,0,-1):
        if a[i-1] > a[i]:
            a[i],a[i-1] = a[i-1],a[i]
            x+=1
            flg=1
print(" ".join([str(i) for i in a]))
print(x) 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(" ")] x=0 x 0 flg=1 flg 1 while flg:
    flg=0
    for i in range(n-1,0,-1):
        if a[i-1] > a[i]:
            a[i],a[i-1] = a[i-1],a[i]
            x+=1
            flg=1 flg flg=0 flg 0 for i in range(n-1,0,-1):
        if a[i-1] > a[i]:
            a[i],a[i-1] = a[i-1],a[i]
            x+=1
            flg=1 i range(n-1,0,-1) range n-1 n 1 0 -1 if a[i-1] > a[i]:
            a[i],a[i-1] = a[i-1],a[i]
            x+=1
            flg=1 a[i-1] > a[i] a[i-1] a i-1 i 1 a[i] a i 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 x+=1 x 1 flg=1 flg 1 str(i) for i in a for i in a i a for i in a str(i) str i print(" ".join([str(i) for i in a])) print " ".join([str(i) for i in a]) " ".join " " join [str(i) for i in a] print(x) print x x+=1 1 x flg=1 1 flg flg=0 0 flg n=int(input()) int(input()) n flg=1 1 flg x=0 0 x a=[int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] a
n=int(input())
a=[int(i) for i in input().split(" ")]
x=0
flg=1
while flg:
    flg=0
    for i in range(n-1,0,-1):
        if a[i-1] > a[i]:
            a[i],a[i-1] = a[i-1],a[i]
            x+=1
            flg=1
print(" ".join([str(i) for i in a]))
print(x)