
n = int(input())
number = list(map(int,input().split()))
count = 0
for i in range(1,n + 1):
    for j in range(1,i):
        
        if number[i - j] < number[i - j - 1]:
            number[i - j],number[i - j - 1] = number[i - j - 1],number[i - j]
            count += 1
number = list(map(str,number))
print(" ".join(number))
print(count) n = int(input()) n int(input()) int input() input number = list(map(int,input().split())) number list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split count = 0 count 0 for i in range(1,n + 1):
    for j in range(1,i):
        
        if number[i - j] < number[i - j - 1]:
            number[i - j],number[i - j - 1] = number[i - j - 1],number[i - j]
            count += 1 i range(1,n + 1) range 1 n + 1 n 1 for j in range(1,i):
        
        if number[i - j] < number[i - j - 1]:
            number[i - j],number[i - j - 1] = number[i - j - 1],number[i - j]
            count += 1 j range(1,i) range 1 i if number[i - j] < number[i - j - 1]:
            number[i - j],number[i - j - 1] = number[i - j - 1],number[i - j]
            count += 1 number[i - j] < number[i - j - 1] number[i - j] number i - j i j number[i - j - 1] number i - j - 1 i - j i j 1 number[i - j],number[i - j - 1] = number[i - j - 1],number[i - j] number[i - j] number i - j i j number[i - j - 1] number i - j - 1 i - j i j 1 number[i - j - 1] number i - j - 1 i - j i j 1 number[i - j] number i - j i j count += 1 count 1 number = list(map(str,number)) number list(map(str,number)) list map(str,number) map str number print(" ".join(number)) print " ".join(number) " ".join " " join number print(count) print count count = 0 0 count number = list(map(int,input().split())) list(map(int,input().split())) number count += 1 1 count n = int(input()) int(input()) n number = list(map(str,number)) list(map(str,number)) number

n = int(input())
number = list(map(int,input().split()))
count = 0
for i in range(1,n + 1):
    for j in range(1,i):
        
        if number[i - j] < number[i - j - 1]:
            number[i - j],number[i - j - 1] = number[i - j - 1],number[i - j]
            count += 1
number = list(map(str,number))
print(" ".join(number))
print(count)