n = input()
nums = input()
nums = nums.split()
nums = list(map(int, nums))

cnt = 0
for i in range(int(n)-1):
    for j in range(int(n)-1):
        if nums[j] > nums[j+1]:
            tmp = nums[j+1]
            nums[j+1] = nums[j]
            nums[j] = tmp
            cnt += 1

print(' '.join(map(str, nums)))
print(cnt) n = input() n input() input nums = input() nums input() input nums = nums.split() nums nums.split() nums.split nums split nums = list(map(int, nums)) nums list(map(int, nums)) list map(int, nums) map int nums cnt = 0 cnt 0 for i in range(int(n)-1):
    for j in range(int(n)-1):
        if nums[j] > nums[j+1]:
            tmp = nums[j+1]
            nums[j+1] = nums[j]
            nums[j] = tmp
            cnt += 1 i range(int(n)-1) range int(n)-1 int(n) int n 1 for j in range(int(n)-1):
        if nums[j] > nums[j+1]:
            tmp = nums[j+1]
            nums[j+1] = nums[j]
            nums[j] = tmp
            cnt += 1 j range(int(n)-1) range int(n)-1 int(n) int n 1 if nums[j] > nums[j+1]:
            tmp = nums[j+1]
            nums[j+1] = nums[j]
            nums[j] = tmp
            cnt += 1 nums[j] > nums[j+1] nums[j] nums j nums[j+1] nums j+1 j 1 tmp = nums[j+1] tmp 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] = tmp nums[j] nums j tmp cnt += 1 cnt 1 print(' '.join(map(str, nums))) print ' '.join(map(str, nums)) ' '.join ' ' join map(str, nums) map str nums print(cnt) print cnt tmp = nums[j+1] nums[j+1] tmp nums = nums.split() nums.split() nums n = input() input() n cnt += 1 1 cnt nums = list(map(int, nums)) list(map(int, nums)) nums cnt = 0 0 cnt nums = input() input() nums
n = input()
nums = input()
nums = nums.split()
nums = list(map(int, nums))

cnt = 0
for i in range(int(n)-1):
    for j in range(int(n)-1):
        if nums[j] > nums[j+1]:
            tmp = nums[j+1]
            nums[j+1] = nums[j]
            nums[j] = tmp
            cnt += 1

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