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

count = 0

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

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

count = 0

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

print(' '.join(map(str,A)))
print(count)

