
if __name__ == '__main__':
    N = (int)(input())
    A = list(map(int,input().split()))

    swapOperation = 0

    flag = 1
    while flag == 1:
        flag = 0
        for j in range( N-1, 0, -1):
            if A[j] < A[j-1]:
                v = A[j]
                A[j]=A[j-1]
                A[j-1]=v
                flag = 1
                swapOperation += 1
    print(" ".join(map(str,A)))
    print(swapOperation) if __name__ == '__main__':
    N = (int)(input())
    A = list(map(int,input().split()))

    swapOperation = 0

    flag = 1
    while flag == 1:
        flag = 0
        for j in range( N-1, 0, -1):
            if A[j] < A[j-1]:
                v = A[j]
                A[j]=A[j-1]
                A[j-1]=v
                flag = 1
                swapOperation += 1
    print(" ".join(map(str,A)))
    print(swapOperation) __name__ == '__main__' __name__ '__main__' 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 swapOperation = 0 swapOperation 0 flag = 1 flag 1 while flag == 1:
        flag = 0
        for j in range( N-1, 0, -1):
            if A[j] < A[j-1]:
                v = A[j]
                A[j]=A[j-1]
                A[j-1]=v
                flag = 1
                swapOperation += 1
     flag == 1 flag 1 flag = 0 flag 0 for j in range( N-1, 0, -1):
            if A[j] < A[j-1]:
                v = A[j]
                A[j]=A[j-1]
                A[j-1]=v
                flag = 1
                swapOperation += 1
     j range( N-1, 0, -1) range N-1 N 1 0 -1 if A[j] < A[j-1]:
                v = A[j]
                A[j]=A[j-1]
                A[j-1]=v
                flag = 1
                swapOperation += 1
     A[j] < A[j-1] A[j] A j A[j-1] A j-1 j 1 v = A[j] v A[j] A j A[j]=A[j-1] A[j] A j A[j-1] A j-1 j 1 A[j-1]=v A[j-1] A j-1 j 1 v flag = 1 flag 1 swapOperation += 1 swapOperation 1 print(" ".join(map(str,A))) print " ".join(map(str,A)) " ".join " " join map(str,A) map str A print(swapOperation) print swapOperation flag = 1 1 flag flag = 0 0 flag swapOperation = 0 0 swapOperation swapOperation += 1 1 swapOperation v = A[j] A[j] v flag = 1 1 flag N = (int)(input()) (int)(input()) N A = list(map(int,input().split())) list(map(int,input().split())) A

if __name__ == '__main__':
    N = (int)(input())
    A = list(map(int,input().split()))

    swapOperation = 0

    flag = 1
    while flag == 1:
        flag = 0
        for j in range( N-1, 0, -1):
            if A[j] < A[j-1]:
                v = A[j]
                A[j]=A[j-1]
                A[j-1]=v
                flag = 1
                swapOperation += 1
    print(" ".join(map(str,A)))
    print(swapOperation)