n = int(input())
A = input().split(' ')
count = 0

flag = True
while flag:
    flag = False
    for j in reversed(range(1, n)):
        if int(A[j]) < int(A[j-1]):
            (A[j-1], A[j]) = (A[j], A[j-1])
            count += 1
            flag = True

print(" ".join(A))
print(count) n = int(input()) n int(input()) int input() input A = input().split(' ') A input().split(' ') ().split () input split ' ' count = 0 count 0 flag = True flag True while flag:
    flag = False
    for j in reversed(range(1, n)):
        if int(A[j]) < int(A[j-1]):
            (A[j-1], A[j]) = (A[j], A[j-1])
            count += 1
            flag = True flag flag = False flag False for j in reversed(range(1, n)):
        if int(A[j]) < int(A[j-1]):
            (A[j-1], A[j]) = (A[j], A[j-1])
            count += 1
            flag = True j reversed(range(1, n)) reversed range(1, n) range 1 n if int(A[j]) < int(A[j-1]):
            (A[j-1], A[j]) = (A[j], A[j-1])
            count += 1
            flag = True int(A[j]) < int(A[j-1]) int(A[j]) int A[j] A j int(A[j-1]) int A[j-1] A j-1 j 1 (A[j-1], A[j]) = (A[j], A[j-1]) (A[j-1], A[j]) A[j-1] A j-1 j 1 A[j] A j (A[j], A[j-1]) A[j] A j A[j-1] A j-1 j 1 count += 1 count 1 flag = True flag True print(" ".join(A)) print " ".join(A) " ".join " " join A print(count) print count count = 0 0 count flag = True True flag count += 1 1 count n = int(input()) int(input()) n flag = False False flag flag = True True flag A = input().split(' ') input().split(' ') A
n = int(input())
A = input().split(' ')
count = 0

flag = True
while flag:
    flag = False
    for j in reversed(range(1, n)):
        if int(A[j]) < int(A[j-1]):
            (A[j-1], A[j]) = (A[j], A[j-1])
            count += 1
            flag = True

print(" ".join(A))
print(count)