def bubble_sort(A):
    count = 0
    for i in range(len(A)):
        for j in range(len(A)-1):
            if A[j+1] < A[j]:
                A[j+1], A[j] = A[j], A[j+1]
                count += 1
    return count

n = int(input())
A = list(map(int, input().split()))
count = bubble_sort(A)
print(*A)
print(count) def bubble_sort(A):
    count = 0
    for i in range(len(A)):
        for j in range(len(A)-1):
            if A[j+1] < A[j]:
                A[j+1], A[j] = A[j], A[j+1]
                count += 1
    return count bubble_sort count = 0 count 0 for i in range(len(A)):
        for j in range(len(A)-1):
            if A[j+1] < A[j]:
                A[j+1], A[j] = A[j], A[j+1]
                count += 1
     i range(len(A)) range len(A) len A for j in range(len(A)-1):
            if A[j+1] < A[j]:
                A[j+1], A[j] = A[j], A[j+1]
                count += 1
     j range(len(A)-1) range len(A)-1 len(A) len A 1 if A[j+1] < A[j]:
                A[j+1], A[j] = A[j], A[j+1]
                count += 1
     A[j+1] < A[j] A[j+1] A j+1 j 1 A[j] A j A[j+1], A[j] = A[j], A[j+1] A[j+1] A j+1 j 1 A[j] A j A[j] A j A[j+1] A j+1 j 1 count += 1 count 1 return count count A A n = int(input()) n int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split count = bubble_sort(A) count bubble_sort(A) bubble_sort A print(*A) print *A A print(count) print count def bubble_sort(A):
    count = 0
    for i in range(len(A)):
        for j in range(len(A)-1):
            if A[j+1] < A[j]:
                A[j+1], A[j] = A[j], A[j+1]
                count += 1
    return count def bubble_sort(A):
    count = 0
    for i in range(len(A)):
        for j in range(len(A)-1):
            if A[j+1] < A[j]:
                A[j+1], A[j] = A[j], A[j+1]
                count += 1
    return count bubble_sort n = int(input()) int(input()) n count = bubble_sort(A) bubble_sort(A) count A = list(map(int, input().split())) list(map(int, input().split())) A
def bubble_sort(A):
    count = 0
    for i in range(len(A)):
        for j in range(len(A)-1):
            if A[j+1] < A[j]:
                A[j+1], A[j] = A[j], A[j+1]
                count += 1
    return count

n = int(input())
A = list(map(int, input().split()))
count = bubble_sort(A)
print(*A)
print(count)
