N = input()
A = map(int,raw_input().split())

flag = 1
x = 0
while flag:
    flag = 0
    for i in range(1,N):
        j = N - i
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            x += 1
            flag = 1

for i in range(N-1):
    print A[i],
print A[-1]

print x N = input() N input() input A = map(int,raw_input().split()) A map(int,raw_input().split()) map int raw_input().split() ().split () raw_input split flag = 1 flag 1 x = 0 x 0 while flag:
    flag = 0
    for i in range(1,N):
        j = N - i
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            x += 1
            flag = 1 flag flag = 0 flag 0 for i in range(1,N):
        j = N - i
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            x += 1
            flag = 1 i range(1,N) range 1 N j = N - i j N - i N i if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            x += 1
            flag = 1 A[j] < A[j-1] A[j] A j A[j-1] A j-1 j 1 v = A[j] v A[j] A j A[j] = A[j-1] A[j] A j A[j-1] A j-1 j 1 A[j-1] = v A[j-1] A j-1 j 1 v x += 1 x 1 flag = 1 flag 1 for i in range(N-1):
    print A[i], i range(N-1) range N-1 N 1 print A[i] A i print A[-1] A -1 print flag = 0 0 flag v = A[j] A[j] v flag = 1 1 flag flag = 1 1 flag x += 1 1 x x = 0 0 x A = map(int,raw_input().split()) map(int,raw_input().split()) A N = input() input() N j = N - i N - i j
N = input()
A = map(int,raw_input().split())

flag = 1
x = 0
while flag:
    flag = 0
    for i in range(1,N):
        j = N - i
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            x += 1
            flag = 1

for i in range(N-1):
    print A[i],
print A[-1]

print x