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

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

flag = True
count = 0
while(flag):
    flag = False
    for i in range(1, N):
        if(a[-i] < a[-i-1]):
            hold = a[-i]
            a[-i] = a[-i-1]
            a[-i-1] = hold
            flag = True
            count += 1
print(" ".join(list(map(str, a))))
print(count)