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

print(count)