#coding:utf-8
n = int(input())
numbers = list(map(int, input().split()))
count = 0

for i in range(n-1):
    for j in range(n-1, i, -1):
        if numbers[j] < numbers[j-1]:
            numbers[j], numbers[j-1] = numbers[j-1], numbers[j]
            count += 1

print(*numbers)
print(count) n = int(input()) n int(input()) int input() input numbers = list(map(int, input().split())) numbers list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split count = 0 count 0 for i in range(n-1):
    for j in range(n-1, i, -1):
        if numbers[j] < numbers[j-1]:
            numbers[j], numbers[j-1] = numbers[j-1], numbers[j]
            count += 1 i range(n-1) range n-1 n 1 for j in range(n-1, i, -1):
        if numbers[j] < numbers[j-1]:
            numbers[j], numbers[j-1] = numbers[j-1], numbers[j]
            count += 1 j range(n-1, i, -1) range n-1 n 1 i -1 if numbers[j] < numbers[j-1]:
            numbers[j], numbers[j-1] = numbers[j-1], numbers[j]
            count += 1 numbers[j] < numbers[j-1] numbers[j] numbers j numbers[j-1] numbers j-1 j 1 numbers[j], numbers[j-1] = numbers[j-1], numbers[j] numbers[j] numbers j numbers[j-1] numbers j-1 j 1 numbers[j-1] numbers j-1 j 1 numbers[j] numbers j count += 1 count 1 print(*numbers) print *numbers numbers print(count) print count numbers = list(map(int, input().split())) list(map(int, input().split())) numbers count = 0 0 count count += 1 1 count n = int(input()) int(input()) n
#coding:utf-8
n = int(input())
numbers = list(map(int, input().split()))
count = 0

for i in range(n-1):
    for j in range(n-1, i, -1):
        if numbers[j] < numbers[j-1]:
            numbers[j], numbers[j-1] = numbers[j-1], numbers[j]
            count += 1

print(*numbers)
print(count)