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

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

print(*A)
print(count) 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 count = 0 count 0 for i in range(N):
    for j in range(N - 1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j - 1] = A[j -1], A[j]
            count += 1 i range(N) range N for j in range(N - 1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j - 1] = A[j -1], A[j]
            count += 1 j range(N - 1, i, -1) range N - 1 N 1 i -1 if A[j] < A[j-1]:
            A[j], A[j - 1] = A[j -1], A[j]
            count += 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 count += 1 count 1 print(*A) print *A A print(count) print count N = int(input()) int(input()) N count = 0 0 count count += 1 1 count A = list(map(int, input().split())) list(map(int, input().split())) A
N = int(input())
A = list(map(int, input().split()))
count = 0

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

print(*A)
print(count)