# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
c = 0
for i in range(n-1):
    for j in range(n-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            c += 1
print(" ".join(map(str, A)))
print(c) 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 c = 0 c 0 for i in range(n-1):
    for j in range(n-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            c += 1 i range(n-1) range n-1 n 1 for j in range(n-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            c += 1 j range(n-1, i, -1) range n-1 n 1 i -1 if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            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 c += 1 c 1 print(" ".join(map(str, A))) print " ".join(map(str, A)) " ".join " " join map(str, A) map str A print(c) print c n = int(input()) int(input()) n c += 1 1 c c = 0 0 c A = list(map(int, input().split())) list(map(int, input().split())) A
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
c = 0
for i in range(n-1):
    for j in range(n-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            c += 1
print(" ".join(map(str, A)))
print(c)