n = int(input())

numbers = [int(i) for i in input().split(" ")]

flag = 1

cnt = 0

while flag:
    flag = 0
    for j in range(n - 1, 0, -1):
        if numbers[j] < numbers[j - 1]:
            numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
            flag = 1
            cnt += 1

numbers = map(str, numbers)
print(" ".join(numbers))

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

numbers = [int(i) for i in input().split(" ")]

flag = 1

cnt = 0

while flag:
    flag = 0
    for j in range(n - 1, 0, -1):
        if numbers[j] < numbers[j - 1]:
            numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
            flag = 1
            cnt += 1

numbers = map(str, numbers)
print(" ".join(numbers))

print(cnt)