data_num = int(input())
nums = list(map(int, input().split(" ")))
cnt = 0
for i in range(data_num):
    for j in range(data_num-1, i,-1):
        if nums[j]<nums[j-1]:
            nums[j], nums[j-1] = nums[j-1], nums[j]
            cnt = cnt + 1

print(" ".join(map(str,nums)) + "\n" + str(cnt)) data_num = int(input()) data_num int(input()) int input() input nums = list(map(int, input().split(" "))) nums list(map(int, input().split(" "))) list map(int, input().split(" ")) map int input().split(" ") ().split () input split " " cnt = 0 cnt 0 for i in range(data_num):
    for j in range(data_num-1, i,-1):
        if nums[j]<nums[j-1]:
            nums[j], nums[j-1] = nums[j-1], nums[j]
            cnt = cnt + 1 i range(data_num) range data_num for j in range(data_num-1, i,-1):
        if nums[j]<nums[j-1]:
            nums[j], nums[j-1] = nums[j-1], nums[j]
            cnt = cnt + 1 j range(data_num-1, i,-1) range data_num-1 data_num 1 i -1 if nums[j]<nums[j-1]:
            nums[j], nums[j-1] = nums[j-1], nums[j]
            cnt = cnt + 1 nums[j]<nums[j-1] nums[j] nums j nums[j-1] nums j-1 j 1 nums[j], nums[j-1] = nums[j-1], nums[j] nums[j] nums j nums[j-1] nums j-1 j 1 nums[j-1] nums j-1 j 1 nums[j] nums j cnt = cnt + 1 cnt cnt + 1 cnt 1 print(" ".join(map(str,nums)) + "\n" + str(cnt)) print " ".join(map(str,nums)) + "\n" + str(cnt) " ".join(map(str,nums)) + "\n" " ".join(map(str,nums)) " ".join " " join map(str,nums) map str nums "\n" str(cnt) str cnt data_num = int(input()) int(input()) data_num cnt = 0 0 cnt nums = list(map(int, input().split(" "))) list(map(int, input().split(" "))) nums cnt = cnt + 1 cnt + 1 cnt
data_num = int(input())
nums = list(map(int, input().split(" ")))
cnt = 0
for i in range(data_num):
    for j in range(data_num-1, i,-1):
        if nums[j]<nums[j-1]:
            nums[j], nums[j-1] = nums[j-1], nums[j]
            cnt = cnt + 1

print(" ".join(map(str,nums)) + "\n" + str(cnt))