n = int(input())
a = [int(i) for i in input().split()]

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

print(" ".join([str(i) for i in a]))
print(count) n = int(input()) n int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i a = [int(i) for i in input().split()] a [int(i) for i in input().split()] count = 0 count 0 flag = True flag True while flag:
    flag = False
    for i in range(n - 1):
        if a[i] > a[i + 1]:
            a[i + 1], a[i] = a[i], a[i + 1]
            count += 1
            flag = True flag flag = False flag False for i in range(n - 1):
        if a[i] > a[i + 1]:
            a[i + 1], a[i] = a[i], a[i + 1]
            count += 1
            flag = True i range(n - 1) range n - 1 n 1 if a[i] > a[i + 1]:
            a[i + 1], a[i] = a[i], a[i + 1]
            count += 1
            flag = True a[i] > a[i + 1] a[i] a i a[i + 1] a i + 1 i 1 a[i + 1], a[i] = a[i], a[i + 1] a[i + 1] a i + 1 i 1 a[i] a i a[i] a i a[i + 1] a i + 1 i 1 count += 1 count 1 flag = True flag True str(i) for i in a for i in a i a for i in a str(i) str i print(" ".join([str(i) for i in a])) print " ".join([str(i) for i in a]) " ".join " " join [str(i) for i in a] print(count) print count flag = True True flag flag = False False flag count += 1 1 count flag = True True flag n = int(input()) int(input()) n count = 0 0 count a = [int(i) for i in input().split()] [int(i) for i in input().split()] a
n = int(input())
a = [int(i) for i in input().split()]

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

print(" ".join([str(i) for i in a]))
print(count)
