#coding: UTF-8

a = int(input())
N = list(map(int, input().split()))

c = 0

for i in range(a - 1):
    for j in range(a-1, i,-1):
        if N[j] < N[j - 1]:
            c+=1
            tmp = N[j]
            N[j] = N[j - 1]
            N[j - 1] = tmp

for i in range(a - 1):
    print(N[i],end=' ')
print(N[a-1]);
print(c); a = int(input()) a int(input()) int input() input N = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c = 0 c 0 for i in range(a - 1):
    for j in range(a-1, i,-1):
        if N[j] < N[j - 1]:
            c+=1
            tmp = N[j]
            N[j] = N[j - 1]
            N[j - 1] = tmp i range(a - 1) range a - 1 a 1 for j in range(a-1, i,-1):
        if N[j] < N[j - 1]:
            c+=1
            tmp = N[j]
            N[j] = N[j - 1]
            N[j - 1] = tmp j range(a-1, i,-1) range a-1 a 1 i -1 if N[j] < N[j - 1]:
            c+=1
            tmp = N[j]
            N[j] = N[j - 1]
            N[j - 1] = tmp N[j] < N[j - 1] N[j] N j N[j - 1] N j - 1 j 1 c+=1 c 1 tmp = N[j] tmp N[j] N j N[j] = N[j - 1] N[j] N j N[j - 1] N j - 1 j 1 N[j - 1] = tmp N[j - 1] N j - 1 j 1 tmp for i in range(a - 1):
    print(N[i],end=' ') i range(a - 1) range a - 1 a 1 print(N[i],end=' ') print N[i] N i end=' ' end ' ' print(N[a-1]) print N[a-1] N a-1 a 1 print(c) print c N = list(map(int, input().split())) list(map(int, input().split())) N a = int(input()) int(input()) a c = 0 0 c tmp = N[j] N[j] tmp c+=1 1 c
#coding: UTF-8

a = int(input())
N = list(map(int, input().split()))

c = 0

for i in range(a - 1):
    for j in range(a-1, i,-1):
        if N[j] < N[j - 1]:
            c+=1
            tmp = N[j]
            N[j] = N[j - 1]
            N[j - 1] = tmp

for i in range(a - 1):
    print(N[i],end=' ')
print(N[a-1]);
print(c);