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

count = 0
flag = True
while flag:
    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]
            count += 1
            flag = True

print(' '.join(list(map(str, 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 flag = True flag True while flag:
    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]
            count += 1
            flag = True flag 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]
            count += 1
            flag = True 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]
            count += 1
            flag = True 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 count += 1 count 1 flag = True flag True print(' '.join(list(map(str, a)))) print ' '.join(list(map(str, a))) ' '.join ' ' join list(map(str, a)) list map(str, a) map str a print(count) print count flag = True True flag a = list(map(int, input().split())) list(map(int, input().split())) a n = int(input()) int(input()) n flag = True True flag count += 1 1 count flag = False False flag count = 0 0 count
n = int(input())
a = list(map(int, input().split()))

count = 0
flag = True
while flag:
    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]
            count += 1
            flag = True

print(' '.join(list(map(str, a))))
print(count)