n = int(input())
s = input().split(" ")
nums = list(map(int,s))
flag = 1
koukan = 0
while flag:
    flag = 0
    for i in range(n-1, 0, -1):
        if nums[i] < nums[i-1]:
            w = nums[i]
            nums[i] = nums[i-1]
            nums[i-1] = w
            koukan += 1
            flag = 1
for i in range(n):
    if i == n-1:
        print(nums[i])
    else:
        print(nums[i],end=" ")
print(koukan) n = int(input()) n int(input()) int input() input s = input().split(" ") s input().split(" ") ().split () input split " " nums = list(map(int,s)) nums list(map(int,s)) list map(int,s) map int s flag = 1 flag 1 koukan = 0 koukan 0 while flag:
    flag = 0
    for i in range(n-1, 0, -1):
        if nums[i] < nums[i-1]:
            w = nums[i]
            nums[i] = nums[i-1]
            nums[i-1] = w
            koukan += 1
            flag = 1 flag flag = 0 flag 0 for i in range(n-1, 0, -1):
        if nums[i] < nums[i-1]:
            w = nums[i]
            nums[i] = nums[i-1]
            nums[i-1] = w
            koukan += 1
            flag = 1 i range(n-1, 0, -1) range n-1 n 1 0 -1 if nums[i] < nums[i-1]:
            w = nums[i]
            nums[i] = nums[i-1]
            nums[i-1] = w
            koukan += 1
            flag = 1 nums[i] < nums[i-1] nums[i] nums i nums[i-1] nums i-1 i 1 w = nums[i] w nums[i] nums i nums[i] = nums[i-1] nums[i] nums i nums[i-1] nums i-1 i 1 nums[i-1] = w nums[i-1] nums i-1 i 1 w koukan += 1 koukan 1 flag = 1 flag 1 for i in range(n):
    if i == n-1:
        print(nums[i])
    else:
        print(nums[i],end=" ") i range(n) range n if i == n-1:
        print(nums[i])
    else:
        print(nums[i],end=" ") i == n-1 i n-1 n 1 print(nums[i]) print nums[i] nums i print(nums[i],end=" ") print nums[i] nums i end=" " end " " print(koukan) print koukan flag = 1 1 flag n = int(input()) int(input()) n nums = list(map(int,s)) list(map(int,s)) nums koukan = 0 0 koukan flag = 0 0 flag w = nums[i] nums[i] w flag = 1 1 flag s = input().split(" ") input().split(" ") s koukan += 1 1 koukan
n = int(input())
s = input().split(" ")
nums = list(map(int,s))
flag = 1
koukan = 0
while flag:
    flag = 0
    for i in range(n-1, 0, -1):
        if nums[i] < nums[i-1]:
            w = nums[i]
            nums[i] = nums[i-1]
            nums[i-1] = w
            koukan += 1
            flag = 1
for i in range(n):
    if i == n-1:
        print(nums[i])
    else:
        print(nums[i],end=" ")
print(koukan)