N = int(input())
A = list(map(int, input().split()))
flag = True
swap = 0
while flag:
    flag = False
    for j in range(N - 1, 0, -1):
        if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            swap += 1
            flag = True
print(" ".join(list(map(str, A))))
print(swap) 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 flag = True flag True swap = 0 swap 0 while flag:
    flag = False
    for j in range(N - 1, 0, -1):
        if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            swap += 1
            flag = True flag flag = False flag False for j in range(N - 1, 0, -1):
        if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            swap += 1
            flag = True j range(N - 1, 0, -1) range N - 1 N 1 0 -1 if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            swap += 1
            flag = True 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 swap += 1 swap 1 flag = True flag True print(" ".join(list(map(str, A)))) print " ".join(list(map(str, A))) " ".join " " join list(map(str, A)) list map(str, A) map str A print(swap) print swap flag = True True flag flag = False False flag N = int(input()) int(input()) N swap = 0 0 swap flag = True True flag A = list(map(int, input().split())) list(map(int, input().split())) A swap += 1 1 swap
N = int(input())
A = list(map(int, input().split()))
flag = True
swap = 0
while flag:
    flag = False
    for j in range(N - 1, 0, -1):
        if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            swap += 1
            flag = True
print(" ".join(list(map(str, A))))
print(swap)