input()
A = [int(i) for i in input().split()]
c = 0
def bubble_sort(A):
    global c
    flag = True
    while flag:
        flag = False
        for i in range(len(A)-1, 0, -1):
            if A[i] < A[i -1]:
                A[i], A[i -1] = A[i -1], A[i]
                c += 1
                flag = True
bubble_sort(A)
print(*A)
print(c) 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 A = [int(i) for i in input().split()] A [int(i) for i in input().split()] c = 0 c 0 def bubble_sort(A):
    global c
    flag = True
    while flag:
        flag = False
        for i in range(len(A)-1, 0, -1):
            if A[i] < A[i -1]:
                A[i], A[i -1] = A[i -1], A[i]
                c += 1
                flag = True bubble_sort global c flag = True flag True while flag:
        flag = False
        for i in range(len(A)-1, 0, -1):
            if A[i] < A[i -1]:
                A[i], A[i -1] = A[i -1], A[i]
                c += 1
                flag = True flag flag = False flag False for i in range(len(A)-1, 0, -1):
            if A[i] < A[i -1]:
                A[i], A[i -1] = A[i -1], A[i]
                c += 1
                flag = True i range(len(A)-1, 0, -1) range len(A)-1 len(A) len A 1 0 -1 if A[i] < A[i -1]:
                A[i], A[i -1] = A[i -1], A[i]
                c += 1
                flag = True A[i] < A[i -1] A[i] A i A[i -1] A i -1 i 1 A[i], A[i -1] = A[i -1], A[i] A[i] A i A[i -1] A i -1 i 1 A[i -1] A i -1 i 1 A[i] A i c += 1 c 1 flag = True flag True A A bubble_sort(A) bubble_sort A print(*A) print *A A print(c) print c c = 0 0 c A = [int(i) for i in input().split()] [int(i) for i in input().split()] A def bubble_sort(A):
    global c
    flag = True
    while flag:
        flag = False
        for i in range(len(A)-1, 0, -1):
            if A[i] < A[i -1]:
                A[i], A[i -1] = A[i -1], A[i]
                c += 1
                flag = True def bubble_sort(A):
    global c
    flag = True
    while flag:
        flag = False
        for i in range(len(A)-1, 0, -1):
            if A[i] < A[i -1]:
                A[i], A[i -1] = A[i -1], A[i]
                c += 1
                flag = True bubble_sort
input()
A = [int(i) for i in input().split()]
c = 0
def bubble_sort(A):
    global c
    flag = True
    while flag:
        flag = False
        for i in range(len(A)-1, 0, -1):
            if A[i] < A[i -1]:
                A[i], A[i -1] = A[i -1], A[i]
                c += 1
                flag = True
bubble_sort(A)
print(*A)
print(c)
