N = int(input())
A = [int(x) for x in input().split(" ")]
flag = True
swap_count = 0
i = 0
while flag:
    flag = False
    for j in range(N-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            flag = True
            swap_count += 1
    i += 1

print(*A)
print(swap_count) N = int(input()) N int(input()) int input() input int(x) for x in input().split(" ") for x in input().split(" ") x input().split(" ") ().split () input split " " for x in input().split(" ") int(x) int x A = [int(x) for x in input().split(" ")] A [int(x) for x in input().split(" ")] flag = True flag True swap_count = 0 swap_count 0 i = 0 i 0 while flag:
    flag = False
    for j in range(N-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            flag = True
            swap_count += 1
    i += 1 flag flag = False flag False for j in range(N-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            flag = True
            swap_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]
            flag = True
            swap_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 flag = True flag True swap_count += 1 swap_count 1 i += 1 i 1 print(*A) print *A A print(swap_count) print swap_count N = int(input()) int(input()) N A = [int(x) for x in input().split(" ")] [int(x) for x in input().split(" ")] A flag = True True flag swap_count = 0 0 swap_count swap_count += 1 1 swap_count i += 1 1 i flag = True True flag i = 0 0 i flag = False False flag
N = int(input())
A = [int(x) for x in input().split(" ")]
flag = True
swap_count = 0
i = 0
while flag:
    flag = False
    for j in range(N-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            flag = True
            swap_count += 1
    i += 1

print(*A)
print(swap_count)