n = int(input())
m = list(map(int, input().split()))

count = 0
flag = 1
while flag:
    flag = 0
    for j in range(n-1, 0, -1):
        if m[j] < m[j-1]:
            m[j], m[j-1] = m[j-1], m[j]
            count += 1
            flag = 1

print(" ".join(str(x) for x in m))
print(count) n = int(input()) n int(input()) int input() input m = list(map(int, input().split())) m list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split count = 0 count 0 flag = 1 flag 1 while flag:
    flag = 0
    for j in range(n-1, 0, -1):
        if m[j] < m[j-1]:
            m[j], m[j-1] = m[j-1], m[j]
            count += 1
            flag = 1 flag flag = 0 flag 0 for j in range(n-1, 0, -1):
        if m[j] < m[j-1]:
            m[j], m[j-1] = m[j-1], m[j]
            count += 1
            flag = 1 j range(n-1, 0, -1) range n-1 n 1 0 -1 if m[j] < m[j-1]:
            m[j], m[j-1] = m[j-1], m[j]
            count += 1
            flag = 1 m[j] < m[j-1] m[j] m j m[j-1] m j-1 j 1 m[j], m[j-1] = m[j-1], m[j] m[j] m j m[j-1] m j-1 j 1 m[j-1] m j-1 j 1 m[j] m j count += 1 count 1 flag = 1 flag 1 print(" ".join(str(x) for x in m)) print " ".join(str(x) for x in m) " ".join " " join str(x) str x print(count) print count m = list(map(int, input().split())) list(map(int, input().split())) m flag = 0 0 flag count += 1 1 count n = int(input()) int(input()) n count = 0 0 count flag = 1 1 flag flag = 1 1 flag
n = int(input())
m = list(map(int, input().split()))

count = 0
flag = 1
while flag:
    flag = 0
    for j in range(n-1, 0, -1):
        if m[j] < m[j-1]:
            m[j], m[j-1] = m[j-1], m[j]
            count += 1
            flag = 1

print(" ".join(str(x) for x in m))
print(count)