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

last  = 0
count = 0
flag  = True

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

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

last  = 0
count = 0
flag  = True

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

print(*a)
print(count)