
num_length = int(input())
num_array = [int(x) for x in input().split()]

def bubbleSort(A, N):
    flag = 1
    exchange_counter = 0
    while flag:
        flag = 0
        for i in range(1, N):
            if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                flag = 1
                exchange_counter += 1
    print(" ".join(map(str, A)))
    print(exchange_counter)

bubbleSort(num_array, num_length) num_length = int(input()) num_length int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x num_array = [int(x) for x in input().split()] num_array [int(x) for x in input().split()] def bubbleSort(A, N):
    flag = 1
    exchange_counter = 0
    while flag:
        flag = 0
        for i in range(1, N):
            if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                flag = 1
                exchange_counter += 1
    print(" ".join(map(str, A)))
    print(exchange_counter) bubbleSort flag = 1 flag 1 exchange_counter = 0 exchange_counter 0 while flag:
        flag = 0
        for i in range(1, N):
            if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                flag = 1
                exchange_counter += 1
     flag flag = 0 flag 0 for i in range(1, N):
            if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                flag = 1
                exchange_counter += 1
     i range(1, N) range 1 N if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                flag = 1
                exchange_counter += 1
     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 flag = 1 flag 1 exchange_counter += 1 exchange_counter 1 print(" ".join(map(str, A))) print " ".join(map(str, A)) " ".join " " join map(str, A) map str A print(exchange_counter) print exchange_counter A A N N bubbleSort(num_array, num_length) bubbleSort num_array num_length num_length = int(input()) int(input()) num_length def bubbleSort(A, N):
    flag = 1
    exchange_counter = 0
    while flag:
        flag = 0
        for i in range(1, N):
            if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                flag = 1
                exchange_counter += 1
    print(" ".join(map(str, A)))
    print(exchange_counter) def bubbleSort(A, N):
    flag = 1
    exchange_counter = 0
    while flag:
        flag = 0
        for i in range(1, N):
            if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                flag = 1
                exchange_counter += 1
    print(" ".join(map(str, A)))
    print(exchange_counter) bubbleSort num_array = [int(x) for x in input().split()] [int(x) for x in input().split()] num_array

num_length = int(input())
num_array = [int(x) for x in input().split()]

def bubbleSort(A, N):
    flag = 1
    exchange_counter = 0
    while flag:
        flag = 0
        for i in range(1, N):
            if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                flag = 1
                exchange_counter += 1
    print(" ".join(map(str, A)))
    print(exchange_counter)

bubbleSort(num_array, num_length)