N = int(input())
A = [int(A) for A in input().split()]
cnt = 0
for i in range(1, N):
    for j in range(N-1, i-1, -1):
        if A[j] < A[j-1]:
            t = A[j]
            A[j] = A[j-1]
            A[j-1] = t
            cnt += 1
for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print("{}".format(A[i]), end=' ')

print(cnt) N = int(input()) N int(input()) int input() input int(A) for A in input().split() for A in input().split() A input().split() ().split () input split for A in input().split() int(A) int A A = [int(A) for A in input().split()] A [int(A) for A in input().split()] cnt = 0 cnt 0 for i in range(1, N):
    for j in range(N-1, i-1, -1):
        if A[j] < A[j-1]:
            t = A[j]
            A[j] = A[j-1]
            A[j-1] = t
            cnt += 1 i range(1, N) range 1 N for j in range(N-1, i-1, -1):
        if A[j] < A[j-1]:
            t = A[j]
            A[j] = A[j-1]
            A[j-1] = t
            cnt += 1 j range(N-1, i-1, -1) range N-1 N 1 i-1 i 1 -1 if A[j] < A[j-1]:
            t = A[j]
            A[j] = A[j-1]
            A[j-1] = t
            cnt += 1 A[j] < A[j-1] A[j] A j A[j-1] A j-1 j 1 t = A[j] t A[j] A j A[j] = A[j-1] A[j] A j A[j-1] A j-1 j 1 A[j-1] = t A[j-1] A j-1 j 1 t cnt += 1 cnt 1 for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print("{}".format(A[i]), end=' ') i range(N) range N if i == N - 1:
        print(A[i])
    else:
        print("{}".format(A[i]), end=' ') i == N - 1 i N - 1 N 1 print(A[i]) print A[i] A i print("{}".format(A[i]), end=' ') print "{}".format(A[i]) "{}".format "{}" format A[i] A i end=' ' end ' ' print(cnt) print cnt N = int(input()) int(input()) N t = A[j] A[j] t cnt = 0 0 cnt A = [int(A) for A in input().split()] [int(A) for A in input().split()] A cnt += 1 1 cnt
N = int(input())
A = [int(A) for A in input().split()]
cnt = 0
for i in range(1, N):
    for j in range(N-1, i-1, -1):
        if A[j] < A[j-1]:
            t = A[j]
            A[j] = A[j-1]
            A[j-1] = t
            cnt += 1
for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print("{}".format(A[i]), end=' ')

print(cnt)