n = int(input())
L = list(map(int, input().split()))
p = 0
for _ in L:
    for j in range(n-1, 0, -1):
        if L[j] < L[j-1]:
            L[j], L[j-1] = L[j-1], L[j]
            p += 1
print(*L)
print(p) n = int(input()) n int(input()) int input() input L = list(map(int, input().split())) L list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split p = 0 p 0 for _ in L:
    for j in range(n-1, 0, -1):
        if L[j] < L[j-1]:
            L[j], L[j-1] = L[j-1], L[j]
            p += 1 _ L for j in range(n-1, 0, -1):
        if L[j] < L[j-1]:
            L[j], L[j-1] = L[j-1], L[j]
            p += 1 j range(n-1, 0, -1) range n-1 n 1 0 -1 if L[j] < L[j-1]:
            L[j], L[j-1] = L[j-1], L[j]
            p += 1 L[j] < L[j-1] L[j] L j L[j-1] L j-1 j 1 L[j], L[j-1] = L[j-1], L[j] L[j] L j L[j-1] L j-1 j 1 L[j-1] L j-1 j 1 L[j] L j p += 1 p 1 print(*L) print *L L print(p) print p p += 1 1 p n = int(input()) int(input()) n L = list(map(int, input().split())) list(map(int, input().split())) L p = 0 0 p
n = int(input())
L = list(map(int, input().split()))
p = 0
for _ in L:
    for j in range(n-1, 0, -1):
        if L[j] < L[j-1]:
            L[j], L[j-1] = L[j-1], L[j]
            p += 1
print(*L)
print(p)