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

count = 0
flag  = 1

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

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

count = 0
flag  = 1

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

print(*a)
print(count)