N = int(raw_input())
nums = map(int, raw_input().split(" "))

count = 0
for i in range(0, len(nums)):
    for j in range(len(nums)-1, i, -1):
        if nums[j-1] > nums[j]:
            temp = nums[j-1]
            nums[j-1] = nums[j]
            nums[j] = temp
            count += 1

nums = map(str, nums)
print(" ".join(nums))
print(count) N = int(raw_input()) N int(raw_input()) int raw_input() raw_input nums = map(int, raw_input().split(" ")) nums map(int, raw_input().split(" ")) map int raw_input().split(" ") ().split () raw_input split " " count = 0 count 0 for i in range(0, len(nums)):
    for j in range(len(nums)-1, i, -1):
        if nums[j-1] > nums[j]:
            temp = nums[j-1]
            nums[j-1] = nums[j]
            nums[j] = temp
            count += 1 i range(0, len(nums)) range 0 len(nums) len nums for j in range(len(nums)-1, i, -1):
        if nums[j-1] > nums[j]:
            temp = nums[j-1]
            nums[j-1] = nums[j]
            nums[j] = temp
            count += 1 j range(len(nums)-1, i, -1) range len(nums)-1 len(nums) len nums 1 i -1 if nums[j-1] > nums[j]:
            temp = nums[j-1]
            nums[j-1] = nums[j]
            nums[j] = temp
            count += 1 nums[j-1] > nums[j] nums[j-1] nums j-1 j 1 nums[j] nums j temp = nums[j-1] temp nums[j-1] nums j-1 j 1 nums[j-1] = nums[j] nums[j-1] nums j-1 j 1 nums[j] nums j nums[j] = temp nums[j] nums j temp count += 1 count 1 nums = map(str, nums) nums map(str, nums) map str nums print(" ".join(nums)) print " ".join(nums) " ".join " " join nums print(count) print count count = 0 0 count count += 1 1 count nums = map(str, nums) map(str, nums) nums nums = map(int, raw_input().split(" ")) map(int, raw_input().split(" ")) nums temp = nums[j-1] nums[j-1] temp N = int(raw_input()) int(raw_input()) N
N = int(raw_input())
nums = map(int, raw_input().split(" "))

count = 0
for i in range(0, len(nums)):
    for j in range(len(nums)-1, i, -1):
        if nums[j-1] > nums[j]:
            temp = nums[j-1]
            nums[j-1] = nums[j]
            nums[j] = temp
            count += 1

nums = map(str, nums)
print(" ".join(nums))
print(count)