n = int(input())
a = list(map(int, input().split()))
count = 0

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

print(*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 for i in range(n-1):
    for j in range(n-1, i, -1):
        if a[j-1] > a[j]:
            a[j-1], a[j] = a[j], a[j-1]
            count += 1 i range(n-1) range n-1 n 1 for j in range(n-1, i, -1):
        if a[j-1] > a[j]:
            a[j-1], a[j] = a[j], a[j-1]
            count += 1 j range(n-1, i, -1) range n-1 n 1 i -1 if a[j-1] > a[j]:
            a[j-1], a[j] = a[j], a[j-1]
            count += 1 a[j-1] > a[j] a[j-1] a j-1 j 1 a[j] a j 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 count += 1 count 1 print(*a) print *a a print(count) print count a = list(map(int, input().split())) list(map(int, input().split())) a count = 0 0 count count += 1 1 count n = int(input()) int(input()) n
n = int(input())
a = list(map(int, input().split()))
count = 0

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

print(*a)
print(count)
