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

flag = 1
cnt = 0
while flag:
    flag = 0
    # ????????????????????????
    for j in reversed(range(1, N)):
        # 1?????????????´???¨??????
        if A[j] < A[j-1]:
            # 1???????????????????°????????????°??????
            A[j], A[j-1] = A[j-1], A[j]
            flag = 1
            cnt += 1

print(' '.join(map(str, A)))
print(cnt) 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 = 1 flag 1 cnt = 0 cnt 0 while flag:
    flag = 0
    # ????????????????????????
    for j in reversed(range(1, N)):
        # 1?????????????´???¨??????
        if A[j] < A[j-1]:
            # 1???????????????????°????????????°??????
            A[j], A[j-1] = A[j-1], A[j]
            flag = 1
            cnt += 1 flag flag = 0 flag 0 for j in reversed(range(1, N)):
        # 1?????????????´???¨??????
        if A[j] < A[j-1]:
            # 1???????????????????°????????????°??????
            A[j], A[j-1] = A[j-1], A[j]
            flag = 1
            cnt += 1 j reversed(range(1, N)) reversed range(1, N) range 1 N if A[j] < A[j-1]:
            # 1???????????????????°????????????°??????
            A[j], A[j-1] = A[j-1], A[j]
            flag = 1
            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 flag = 1 flag 1 cnt += 1 cnt 1 print(' '.join(map(str, A))) print ' '.join(map(str, A)) ' '.join ' ' join map(str, A) map str A print(cnt) print cnt flag = 1 1 flag cnt += 1 1 cnt cnt = 0 0 cnt flag = 0 0 flag N = int(input()) int(input()) N flag = 1 1 flag A = list(map(int, input().split())) list(map(int, input().split())) A
N = int(input())
A = list(map(int, input().split()))

flag = 1
cnt = 0
while flag:
    flag = 0
    # ????????????????????????
    for j in reversed(range(1, N)):
        # 1?????????????´???¨??????
        if A[j] < A[j-1]:
            # 1???????????????????°????????????°??????
            A[j], A[j-1] = A[j-1], A[j]
            flag = 1
            cnt += 1

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