n = int(input())

numbers = list(map(int, input().split(" ")))

cnt = 0

for i in range(n):
    for j in range(n - 1, i, -1):
        if numbers[j] < numbers[j - 1]:
            tmp = numbers[j]
            numbers[j] = numbers[j - 1]
            numbers[j - 1] = tmp
            cnt += 1

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

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

numbers = list(map(int, input().split(" ")))

cnt = 0

for i in range(n):
    for j in range(n - 1, i, -1):
        if numbers[j] < numbers[j - 1]:
            tmp = numbers[j]
            numbers[j] = numbers[j - 1]
            numbers[j - 1] = tmp
            cnt += 1

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

print(cnt)