N = int(input())
A = list(map(int, input().split()))
n = N
cnt = 0
while n > 0:
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            t = A[i]
            A[i] = A[i-1]
            A[i-1] = t
            cnt += 1
    n -= 1
for i in range(N):
    if i == N - 1:
        print(str(A[i]))
    else:
        print(str(A[i]) + " ", end = "")
print(cnt) 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 n = N n N cnt = 0 cnt 0 while n > 0:
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            t = A[i]
            A[i] = A[i-1]
            A[i-1] = t
            cnt += 1
    n -= 1 n > 0 n 0 for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            t = A[i]
            A[i] = A[i-1]
            A[i-1] = t
            cnt += 1
     i range(N-1, 0, -1) range N-1 N 1 0 -1 if A[i] < A[i-1]:
            t = A[i]
            A[i] = A[i-1]
            A[i-1] = t
            cnt += 1
     A[i] < A[i-1] A[i] A i A[i-1] A i-1 i 1 t = A[i] t A[i] A i A[i] = A[i-1] A[i] A i A[i-1] A i-1 i 1 A[i-1] = t A[i-1] A i-1 i 1 t cnt += 1 cnt 1 n -= 1 n 1 for i in range(N):
    if i == N - 1:
        print(str(A[i]))
    else:
        print(str(A[i]) + " ", end = "") i range(N) range N if i == N - 1:
        print(str(A[i]))
    else:
        print(str(A[i]) + " ", end = "") i == N - 1 i N - 1 N 1 print(str(A[i])) print str(A[i]) str A[i] A i print(str(A[i]) + " ", end = "") print str(A[i]) + " " str(A[i]) str A[i] A i " " end = "" end "" print(cnt) print cnt n = N N n n -= 1 1 n cnt += 1 1 cnt A = list(map(int, input().split())) list(map(int, input().split())) A N = int(input()) int(input()) N t = A[i] A[i] t cnt = 0 0 cnt
N = int(input())
A = list(map(int, input().split()))
n = N
cnt = 0
while n > 0:
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            t = A[i]
            A[i] = A[i-1]
            A[i-1] = t
            cnt += 1
    n -= 1
for i in range(N):
    if i == N - 1:
        print(str(A[i]))
    else:
        print(str(A[i]) + " ", end = "")
print(cnt)