N = int(input())
A = list(map(int, input().split()))
sw = 0
for i in range(N-1):
    for j in range(N-1,i,-1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            sw += 1
print(" ".join(map(str, A)))
print(sw) 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 sw = 0 sw 0 for i in range(N-1):
    for j in range(N-1,i,-1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            sw += 1 i range(N-1) range N-1 N 1 for j in range(N-1,i,-1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            sw += 1 j range(N-1,i,-1) range N-1 N 1 i -1 if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            sw += 1 A[j] < A[j-1] A[j] A j A[j-1] A j-1 j 1 A[j], A[j-1] = A[j-1], A[j] A[j] A j A[j-1] A j-1 j 1 A[j-1] A j-1 j 1 A[j] A j sw += 1 sw 1 print(" ".join(map(str, A))) print " ".join(map(str, A)) " ".join " " join map(str, A) map str A print(sw) print sw N = int(input()) int(input()) N sw += 1 1 sw A = list(map(int, input().split())) list(map(int, input().split())) A sw = 0 0 sw
N = int(input())
A = list(map(int, input().split()))
sw = 0
for i in range(N-1):
    for j in range(N-1,i,-1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            sw += 1
print(" ".join(map(str, A)))
print(sw)
