n, data = int(input()), list(map(int, input().split()))
i, t = 0, 0
while i != n-1:
    for j in range(n-1, i, -1):
        if data[j-1] > data[j]:
            data[j-1], data[j] = data[j], data[j-1]
            t += 1
    i += 1
print(" ".join(map(str, data)))
print(t)
 n, data = int(input()), list(map(int, input().split())) n int(input()) int input() input data list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split i, t = 0, 0 i 0 t 0 while i != n-1:
    for j in range(n-1, i, -1):
        if data[j-1] > data[j]:
            data[j-1], data[j] = data[j], data[j-1]
            t += 1
    i += 1 i != n-1 i n-1 n 1 for j in range(n-1, i, -1):
        if data[j-1] > data[j]:
            data[j-1], data[j] = data[j], data[j-1]
            t += 1
     j range(n-1, i, -1) range n-1 n 1 i -1 if data[j-1] > data[j]:
            data[j-1], data[j] = data[j], data[j-1]
            t += 1
     data[j-1] > data[j] data[j-1] data j-1 j 1 data[j] data j data[j-1], data[j] = data[j], data[j-1] data[j-1] data j-1 j 1 data[j] data j data[j] data j data[j-1] data j-1 j 1 t += 1 t 1 i += 1 i 1 print(" ".join(map(str, data))) print " ".join(map(str, data)) " ".join " " join map(str, data) map str data print(t) print t n, data = int(input()), list(map(int, input().split())) int(input()) n data = int(input()), list(map(int, input().split())) list(map(int, input().split())) data t += 1 1 t i, t = 0, 0 0 i t = 0, 0 0 t i += 1 1 i
n, data = int(input()), list(map(int, input().split()))
i, t = 0, 0
while i != n-1:
    for j in range(n-1, i, -1):
        if data[j-1] > data[j]:
            data[j-1], data[j] = data[j], data[j-1]
            t += 1
    i += 1
print(" ".join(map(str, data)))
print(t)

