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


while True:
    flag = 0

    for j in range(n - 1):
        if (nums[j + 1] < nums[j]):
            temp = nums[j]
            nums[j] = nums[j + 1]
            nums[j + 1] = temp
            count += 1
            flag = 1

    if flag != 1:
        break

print(' '.join([str(i) for i in nums]))
print(count)
 n = int(input()) n 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 count = 0 count 0 while True:
    flag = 0

    for j in range(n - 1):
        if (nums[j + 1] < nums[j]):
            temp = nums[j]
            nums[j] = nums[j + 1]
            nums[j + 1] = temp
            count += 1
            flag = 1

    if flag != 1:
        break True flag = 0 flag 0 for j in range(n - 1):
        if (nums[j + 1] < nums[j]):
            temp = nums[j]
            nums[j] = nums[j + 1]
            nums[j + 1] = temp
            count += 1
            flag = 1

     j range(n - 1) range n - 1 n 1 if (nums[j + 1] < nums[j]):
            temp = nums[j]
            nums[j] = nums[j + 1]
            nums[j + 1] = temp
            count += 1
            flag = 1

     nums[j + 1] < nums[j] nums[j + 1] nums j + 1 j 1 nums[j] nums j temp = nums[j] temp nums[j] nums j nums[j] = nums[j + 1] nums[j] nums j nums[j + 1] nums j + 1 j 1 nums[j + 1] = temp nums[j + 1] nums j + 1 j 1 temp count += 1 count 1 flag = 1 flag 1 if flag != 1:
        break flag != 1 flag 1 break str(i) for i in nums for i in nums i nums for i in nums str(i) str i print(' '.join([str(i) for i in nums])) print ' '.join([str(i) for i in nums]) ' '.join ' ' join [str(i) for i in nums] print(count) print count count = 0 0 count flag = 1 1 flag count += 1 1 count n = int(input()) int(input()) n nums = list(map(int, input().split())) list(map(int, input().split())) nums flag = 0 0 flag temp = nums[j] nums[j] temp
n = int(input())
nums = list(map(int, input().split()))
count = 0


while True:
    flag = 0

    for j in range(n - 1):
        if (nums[j + 1] < nums[j]):
            temp = nums[j]
            nums[j] = nums[j + 1]
            nums[j + 1] = temp
            count += 1
            flag = 1

    if flag != 1:
        break

print(' '.join([str(i) for i in nums]))
print(count)

