x = int(input())
y = input()
y = list(map(int, y.split()))
r = sorted(y)
c = 0
while y != r:
    for i, j in enumerate(y[:-1]):
        if y[i] > y[i+1]:
            y[i], y[i+1] = y[i+1], y[i]
            c += 1
print(*y)
print(c) x = int(input()) x int(input()) int input() input y = input() y input() input y = list(map(int, y.split())) y list(map(int, y.split())) list map(int, y.split()) map int y.split() y.split y split r = sorted(y) r sorted(y) sorted y c = 0 c 0 while y != r:
    for i, j in enumerate(y[:-1]):
        if y[i] > y[i+1]:
            y[i], y[i+1] = y[i+1], y[i]
            c += 1 y != r y r for i, j in enumerate(y[:-1]):
        if y[i] > y[i+1]:
            y[i], y[i+1] = y[i+1], y[i]
            c += 1 i j enumerate(y[:-1]) enumerate y[:-1] y :-1 -1 if y[i] > y[i+1]:
            y[i], y[i+1] = y[i+1], y[i]
            c += 1 y[i] > y[i+1] y[i] y i y[i+1] y i+1 i 1 y[i], y[i+1] = y[i+1], y[i] y[i] y i y[i+1] y i+1 i 1 y[i+1] y i+1 i 1 y[i] y i c += 1 c 1 print(*y) print *y y print(c) print c y = list(map(int, y.split())) list(map(int, y.split())) y y = input() input() y c += 1 1 c x = int(input()) int(input()) x r = sorted(y) sorted(y) r c = 0 0 c
x = int(input())
y = input()
y = list(map(int, y.split()))
r = sorted(y)
c = 0
while y != r:
    for i, j in enumerate(y[:-1]):
        if y[i] > y[i+1]:
            y[i], y[i+1] = y[i+1], y[i]
            c += 1
print(*y)
print(c)