N = int(raw_input())
A = map(int, raw_input().split())
i = 0
flag = 1
while flag:
    flag = 0
    for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            A_j = A[j]
            A[j] = A[j-1]
            A[j-1] = A_j
            flag = 1
            i += 1
print " ".join(map(str, A))
print i N = int(raw_input()) N int(raw_input()) int raw_input() raw_input A = map(int, raw_input().split()) A map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split i = 0 i 0 flag = 1 flag 1 while flag:
    flag = 0
    for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            A_j = A[j]
            A[j] = A[j-1]
            A[j-1] = A_j
            flag = 1
            i += 1 flag flag = 0 flag 0 for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            A_j = A[j]
            A[j] = A[j-1]
            A[j-1] = A_j
            flag = 1
            i += 1 j range(N-1, 0, -1) range N-1 N 1 0 -1 if A[j] < A[j-1]:
            A_j = A[j]
            A[j] = A[j-1]
            A[j-1] = A_j
            flag = 1
            i += 1 A[j] < A[j-1] A[j] A j A[j-1] A j-1 j 1 A_j = A[j] A_j A[j] A j A[j] = A[j-1] A[j] A j A[j-1] A j-1 j 1 A[j-1] = A_j A[j-1] A j-1 j 1 A_j flag = 1 flag 1 i += 1 i 1 print " ".join(map(str, A)) " ".join " " join map(str, A) map str A print flag = 0 0 flag i = 0 0 i flag = 1 1 flag flag = 1 1 flag N = int(raw_input()) int(raw_input()) N A_j = A[j] A[j] A_j i += 1 1 i A = map(int, raw_input().split()) map(int, raw_input().split()) A
N = int(raw_input())
A = map(int, raw_input().split())
i = 0
flag = 1
while flag:
    flag = 0
    for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            A_j = A[j]
            A[j] = A[j-1]
            A[j-1] = A_j
            flag = 1
            i += 1
print " ".join(map(str, A))
print i