N = int(input())
A = list(map(int,input().split()))

def sort():
    flag = 1
    swap = 0
    while flag:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A [j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
                swap += 1
                flag = 1
    pr(A)
    print(swap)

def pr(list):
    n = len(list)
    for i in range(n):
        if i < n-1:
            print(list[i],end=" ")
        else:
            print(list[i],end="\n")

sort()
 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 def sort():
    flag = 1
    swap = 0
    while flag:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A [j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
                swap += 1
                flag = 1
    pr(A)
    print(swap) sort flag = 1 flag 1 swap = 0 swap 0 while flag:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A [j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
                swap += 1
                flag = 1
     flag flag = 0 flag 0 for j in range(N-1,0,-1):
            if A[j] < A [j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
                swap += 1
                flag = 1
     j range(N-1,0,-1) range N-1 N 1 0 -1 if A[j] < A [j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
                swap += 1
                flag = 1
     A[j] < A [j-1] A[j] A j A [j-1] A j-1 j 1 temp = A[j] temp A[j] A j A[j] = A[j-1] A[j] A j A[j-1] A j-1 j 1 A[j-1] = temp A[j-1] A j-1 j 1 temp swap += 1 swap 1 flag = 1 flag 1 pr(A) pr A print(swap) print swap def pr(list):
    n = len(list)
    for i in range(n):
        if i < n-1:
            print(list[i],end=" ")
        else:
            print(list[i],end="\n") pr n = len(list) n len(list) len list for i in range(n):
        if i < n-1:
            print(list[i],end=" ")
        else:
            print(list[i],end="\n") i range(n) range n if i < n-1:
            print(list[i],end=" ")
        else:
            print(list[i],end="\n") i < n-1 i n-1 n 1 print(list[i],end=" ") print list[i] list i end=" " end " " print(list[i],end="\n") print list[i] list i end="\n" end "\n" list list sort() sort N = int(input()) int(input()) N def sort():
    flag = 1
    swap = 0
    while flag:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A [j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
                swap += 1
                flag = 1
    pr(A)
    print(swap) def sort():
    flag = 1
    swap = 0
    while flag:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A [j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
                swap += 1
                flag = 1
    pr(A)
    print(swap) sort A = list(map(int,input().split())) list(map(int,input().split())) A def pr(list):
    n = len(list)
    for i in range(n):
        if i < n-1:
            print(list[i],end=" ")
        else:
            print(list[i],end="\n") def pr(list):
    n = len(list)
    for i in range(n):
        if i < n-1:
            print(list[i],end=" ")
        else:
            print(list[i],end="\n") pr
N = int(input())
A = list(map(int,input().split()))

def sort():
    flag = 1
    swap = 0
    while flag:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A [j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
                swap += 1
                flag = 1
    pr(A)
    print(swap)

def pr(list):
    n = len(list)
    for i in range(n):
        if i < n-1:
            print(list[i],end=" ")
        else:
            print(list[i],end="\n")

sort()

