n = int(input())
A = [int(i) for i in input().split()]

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

flag = 1
count = 0
while flag:
    flag = 0
    for j in range(n-1,0,-1):
        if A[j] < A[j-1]:
            A[j],A[j-1] = A[j-1],A[j]
            flag = 1
            count += 1
print(" ".join(map(str,A)))
print(count)
