N = int(input())
A = [int(i) for i in input().split()]

cnt = 0

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

print(' '.join([str(item) for item in A]))
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 A = [int(i) for i in input().split()] A [int(i) for i in input().split()] cnt = 0 cnt 0 for i in range(0, N):
    for j in range(i+1, N)[::-1]:
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            cnt = cnt + 1 i range(0, N) range 0 N for j in range(i+1, N)[::-1]:
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            cnt = cnt + 1 j range(i+1, N)[::-1] (i+1, N) range i+1 i 1 N ::-1 -1 if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            cnt = cnt + 1 A[j] < A[j-1] A[j] A j A[j-1] A j-1 j 1 A[j], A[j-1] = A[j-1], A[j] A[j] A j A[j-1] A j-1 j 1 A[j-1] A j-1 j 1 A[j] A j cnt = cnt + 1 cnt cnt + 1 cnt 1 str(item) for item in A for item in A item A for item in A str(item) str item print(' '.join([str(item) for item in A])) print ' '.join([str(item) for item in A]) ' '.join ' ' join [str(item) for item in A] print(cnt) print cnt N = int(input()) int(input()) N cnt = cnt + 1 cnt + 1 cnt A = [int(i) for i in input().split()] [int(i) for i in input().split()] A cnt = 0 0 cnt
N = int(input())
A = [int(i) for i in input().split()]

cnt = 0

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

print(' '.join([str(item) for item in A]))
print(cnt)