N = int(input())
A = [int(i) for i in input().split()]

counter = 0
flag = 1  #????????£??\????´?????????¨??????
while flag:
    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
            counter += 1

print(' '.join([str(A[i]) for i in range(0, N)]))
print(counter) N = int(input()) N int(input()) int 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()] counter = 0 counter 0 flag = 1 flag 1 while flag:
    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
            counter += 1 flag 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
            counter += 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
            counter += 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 counter += 1 counter 1 str(A[i]) for i in range(0, N) for i in range(0, N) i range(0, N) range 0 N for i in range(0, N) str(A[i]) str A[i] A i print(' '.join([str(A[i]) for i in range(0, N)])) print ' '.join([str(A[i]) for i in range(0, N)]) ' '.join ' ' join [str(A[i]) for i in range(0, N)] print(counter) print counter v = A[j] A[j] v counter = 0 0 counter flag = 1 1 flag flag = 1 1 flag counter += 1 1 counter flag = 0 0 flag N = int(input()) int(input()) N A = [int(i) for i in input().split()] [int(i) for i in input().split()] A
N = int(input())
A = [int(i) for i in input().split()]

counter = 0
flag = 1  #????????£??\????´?????????¨??????
while flag:
    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
            counter += 1

print(' '.join([str(A[i]) for i in range(0, N)]))
print(counter)