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

flag = True
swap_count = 0
for i in range(0, n):
    if not flag:
        break
    flag = False
    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 = True
            swap_count += 1

print(' '.join(map(str, a)))
print(swap_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 flag = True flag True swap_count = 0 swap_count 0 for i in range(0, n):
    if not flag:
        break
    flag = False
    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 = True
            swap_count += 1 i range(0, n) range 0 n if not flag:
        break
     not flag flag break flag = False flag False 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 = True
            swap_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 = True
            swap_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 = True flag True swap_count += 1 swap_count 1 print(' '.join(map(str, a))) print ' '.join(map(str, a)) ' '.join ' ' join map(str, a) map str a print(swap_count) print swap_count n = int(input()) int(input()) n a = list(map(int, input().split())) list(map(int, input().split())) a flag = True True flag swap_count = 0 0 swap_count flag = False False flag swap_count += 1 1 swap_count flag = True True flag
n = int(input())
a = list(map(int, input().split()))

flag = True
swap_count = 0
for i in range(0, n):
    if not flag:
        break
    flag = False
    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 = True
            swap_count += 1

print(' '.join(map(str, a)))
print(swap_count)

