n = int(input())

list = [int(i) for i in input().split()]

def bubble(list):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(len(list)-1):
            if list[len(list)-1-i] < list[len(list)-1-i-1]:
                x = list[len(list)-i-1]
                list[len(list)-1-i] = list[len(list)-1-i-1]
                list[len(list)-1-i-1] = x
                flag = 1
                count += 1
    return [list,count]

answer = bubble(list)
for i in range(len(answer[0])):
    print(str(answer[0][i]) + ' ',end='') if i != len(answer[0])-1 else print(answer[0][i])
print(answer[1]) n = int(input()) n int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i list = [int(i) for i in input().split()] list [int(i) for i in input().split()] def bubble(list):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(len(list)-1):
            if list[len(list)-1-i] < list[len(list)-1-i-1]:
                x = list[len(list)-i-1]
                list[len(list)-1-i] = list[len(list)-1-i-1]
                list[len(list)-1-i-1] = x
                flag = 1
                count += 1
    return [list,count] bubble flag = 1 flag 1 count = 0 count 0 while flag == 1:
        flag = 0
        for i in range(len(list)-1):
            if list[len(list)-1-i] < list[len(list)-1-i-1]:
                x = list[len(list)-i-1]
                list[len(list)-1-i] = list[len(list)-1-i-1]
                list[len(list)-1-i-1] = x
                flag = 1
                count += 1
     flag == 1 flag 1 flag = 0 flag 0 for i in range(len(list)-1):
            if list[len(list)-1-i] < list[len(list)-1-i-1]:
                x = list[len(list)-i-1]
                list[len(list)-1-i] = list[len(list)-1-i-1]
                list[len(list)-1-i-1] = x
                flag = 1
                count += 1
     i range(len(list)-1) range len(list)-1 len(list) len list 1 if list[len(list)-1-i] < list[len(list)-1-i-1]:
                x = list[len(list)-i-1]
                list[len(list)-1-i] = list[len(list)-1-i-1]
                list[len(list)-1-i-1] = x
                flag = 1
                count += 1
     list[len(list)-1-i] < list[len(list)-1-i-1] list[len(list)-1-i] list len(list)-1-i len(list)-1 len(list) len list 1 i list[len(list)-1-i-1] list len(list)-1-i-1 len(list)-1-i len(list)-1 len(list) len list 1 i 1 x = list[len(list)-i-1] x list[len(list)-i-1] list len(list)-i-1 len(list)-i len(list) len list i 1 list[len(list)-1-i] = list[len(list)-1-i-1] list[len(list)-1-i] list len(list)-1-i len(list)-1 len(list) len list 1 i list[len(list)-1-i-1] list len(list)-1-i-1 len(list)-1-i len(list)-1 len(list) len list 1 i 1 list[len(list)-1-i-1] = x list[len(list)-1-i-1] list len(list)-1-i-1 len(list)-1-i len(list)-1 len(list) len list 1 i 1 x flag = 1 flag 1 count += 1 count 1 return [list,count] [list,count] list count list list answer = bubble(list) answer bubble(list) bubble list for i in range(len(answer[0])):
    print(str(answer[0][i]) + ' ',end='') if i != len(answer[0])-1 else print(answer[0][i]) i range(len(answer[0])) range len(answer[0]) len answer[0] answer 0 print(str(answer[0][i]) + ' ',end='') if i != len(answer[0])-1 else print(answer[0][i]) i != len(answer[0])-1 i len(answer[0])-1 len(answer[0]) len answer[0] answer 0 1 print(str(answer[0][i]) + ' ',end='') print str(answer[0][i]) + ' ' str(answer[0][i]) str answer[0][i] [0] answer 0 i ' ' end='' end '' print(answer[0][i]) print answer[0][i] [0] answer 0 i print(answer[1]) print answer[1] answer 1 answer = bubble(list) bubble(list) answer n = int(input()) int(input()) n list = [int(i) for i in input().split()] [int(i) for i in input().split()] list def bubble(list):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(len(list)-1):
            if list[len(list)-1-i] < list[len(list)-1-i-1]:
                x = list[len(list)-i-1]
                list[len(list)-1-i] = list[len(list)-1-i-1]
                list[len(list)-1-i-1] = x
                flag = 1
                count += 1
    return [list,count] def bubble(list):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(len(list)-1):
            if list[len(list)-1-i] < list[len(list)-1-i-1]:
                x = list[len(list)-i-1]
                list[len(list)-1-i] = list[len(list)-1-i-1]
                list[len(list)-1-i-1] = x
                flag = 1
                count += 1
    return [list,count] bubble
n = int(input())

list = [int(i) for i in input().split()]

def bubble(list):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(len(list)-1):
            if list[len(list)-1-i] < list[len(list)-1-i-1]:
                x = list[len(list)-i-1]
                list[len(list)-1-i] = list[len(list)-1-i-1]
                list[len(list)-1-i-1] = x
                flag = 1
                count += 1
    return [list,count]

answer = bubble(list)
for i in range(len(answer[0])):
    print(str(answer[0][i]) + ' ',end='') if i != len(answer[0])-1 else print(answer[0][i])
print(answer[1])