length = int(input())
eles = [int(l) for l in input().split()]

times = 0
for i in range(length):
    flag = 1
    while flag > 0:
        flag = 0
        for j in range(length-1, 0, -1):
            if eles[j] < eles[j - 1]:
                _temp = eles[j]
                eles[j] = eles[j-1]
                eles[j-1] = _temp
                flag = 1
                times += 1

print(*eles)
print(times) length = int(input()) length int(input()) int input() input int(l) for l in input().split() for l in input().split() l input().split() ().split () input split for l in input().split() int(l) int l eles = [int(l) for l in input().split()] eles [int(l) for l in input().split()] times = 0 times 0 for i in range(length):
    flag = 1
    while flag > 0:
        flag = 0
        for j in range(length-1, 0, -1):
            if eles[j] < eles[j - 1]:
                _temp = eles[j]
                eles[j] = eles[j-1]
                eles[j-1] = _temp
                flag = 1
                times += 1 i range(length) range length flag = 1 flag 1 while flag > 0:
        flag = 0
        for j in range(length-1, 0, -1):
            if eles[j] < eles[j - 1]:
                _temp = eles[j]
                eles[j] = eles[j-1]
                eles[j-1] = _temp
                flag = 1
                times += 1 flag > 0 flag 0 flag = 0 flag 0 for j in range(length-1, 0, -1):
            if eles[j] < eles[j - 1]:
                _temp = eles[j]
                eles[j] = eles[j-1]
                eles[j-1] = _temp
                flag = 1
                times += 1 j range(length-1, 0, -1) range length-1 length 1 0 -1 if eles[j] < eles[j - 1]:
                _temp = eles[j]
                eles[j] = eles[j-1]
                eles[j-1] = _temp
                flag = 1
                times += 1 eles[j] < eles[j - 1] eles[j] eles j eles[j - 1] eles j - 1 j 1 _temp = eles[j] _temp eles[j] eles j eles[j] = eles[j-1] eles[j] eles j eles[j-1] eles j-1 j 1 eles[j-1] = _temp eles[j-1] eles j-1 j 1 _temp flag = 1 flag 1 times += 1 times 1 print(*eles) print *eles eles print(times) print times flag = 1 1 flag _temp = eles[j] eles[j] _temp times = 0 0 times flag = 1 1 flag flag = 0 0 flag eles = [int(l) for l in input().split()] [int(l) for l in input().split()] eles times += 1 1 times length = int(input()) int(input()) length
length = int(input())
eles = [int(l) for l in input().split()]

times = 0
for i in range(length):
    flag = 1
    while flag > 0:
        flag = 0
        for j in range(length-1, 0, -1):
            if eles[j] < eles[j - 1]:
                _temp = eles[j]
                eles[j] = eles[j-1]
                eles[j-1] = _temp
                flag = 1
                times += 1

print(*eles)
print(times)