N = int(input())

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

flag = 1
num_c  = 0
while(flag):
    flag = 0
    for j in range(1, N):
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            num_c += 1
            flag = 1

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

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

flag = 1
num_c  = 0
while(flag):
    flag = 0
    for j in range(1, N):
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            num_c += 1
            flag = 1

print((" ").join((str(a) for a in A)))
print(num_c)