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

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

print(' '.join(map(str, A)))
print(nSwap) N = int(input()) N int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split nSwap = 0 nSwap 0 for i in range(N):
    for j in range(N-1, i, -1):
        if A[j] < A[j-1]:
            A[j-1], A[j] = A[j], A[j-1]
            nSwap += 1 i range(N) range N for j in range(N-1, i, -1):
        if A[j] < A[j-1]:
            A[j-1], A[j] = A[j], A[j-1]
            nSwap += 1 j range(N-1, i, -1) range N-1 N 1 i -1 if A[j] < A[j-1]:
            A[j-1], A[j] = A[j], A[j-1]
            nSwap += 1 A[j] < A[j-1] A[j] A j A[j-1] A j-1 j 1 A[j-1], A[j] = A[j], A[j-1] A[j-1] A j-1 j 1 A[j] A j A[j] A j A[j-1] A j-1 j 1 nSwap += 1 nSwap 1 print(' '.join(map(str, A))) print ' '.join(map(str, A)) ' '.join ' ' join map(str, A) map str A print(nSwap) print nSwap A = list(map(int, input().split())) list(map(int, input().split())) A nSwap = 0 0 nSwap nSwap += 1 1 nSwap N = int(input()) int(input()) N
N = int(input())
A = list(map(int, input().split()))

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

print(' '.join(map(str, A)))
print(nSwap)