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

count = 0
flag = 1
while flag:
    flag = 0
    for i in range(len(ls)-1, 0, -1):
        if ls[i] < ls[i-1]:
            ls[i], ls[i-1] = ls[i-1], ls[i]
            count += 1
            flag = 1
print(' '.join(map(str, ls)))
print(count) n = int(input()) n int(input()) int input() input ls = list(map(int, input().split())) ls 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 i in range(len(ls)-1, 0, -1):
        if ls[i] < ls[i-1]:
            ls[i], ls[i-1] = ls[i-1], ls[i]
            count += 1
            flag = 1 flag flag = 0 flag 0 for i in range(len(ls)-1, 0, -1):
        if ls[i] < ls[i-1]:
            ls[i], ls[i-1] = ls[i-1], ls[i]
            count += 1
            flag = 1 i range(len(ls)-1, 0, -1) range len(ls)-1 len(ls) len ls 1 0 -1 if ls[i] < ls[i-1]:
            ls[i], ls[i-1] = ls[i-1], ls[i]
            count += 1
            flag = 1 ls[i] < ls[i-1] ls[i] ls i ls[i-1] ls i-1 i 1 ls[i], ls[i-1] = ls[i-1], ls[i] ls[i] ls i ls[i-1] ls i-1 i 1 ls[i-1] ls i-1 i 1 ls[i] ls i count += 1 count 1 flag = 1 flag 1 print(' '.join(map(str, ls))) print ' '.join(map(str, ls)) ' '.join ' ' join map(str, ls) map str ls print(count) print count ls = list(map(int, input().split())) list(map(int, input().split())) ls n = int(input()) int(input()) n flag = 1 1 flag count = 0 0 count flag = 1 1 flag count += 1 1 count flag = 0 0 flag
n = int(input())
ls = list(map(int, input().split()))

count = 0
flag = 1
while flag:
    flag = 0
    for i in range(len(ls)-1, 0, -1):
        if ls[i] < ls[i-1]:
            ls[i], ls[i-1] = ls[i-1], ls[i]
            count += 1
            flag = 1
print(' '.join(map(str, ls)))
print(count)
