N = int(raw_input())
A = map(int, raw_input().split())
count = 0
flag = True
while flag:
    flag = False
    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 = True
            count += 1
print " ".join(map(str, A))
print count 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 count = 0 count 0 flag = True flag True while flag:
    flag = False
    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 = True
            count += 1 flag flag = False flag False 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 = True
            count += 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 = True
            count += 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 = True flag True count += 1 count 1 print " ".join(map(str, A)) " ".join " " join map(str, A) map str A print flag = True True flag A_j = A[j] A[j] A_j N = int(raw_input()) int(raw_input()) N flag = True True flag A = map(int, raw_input().split()) map(int, raw_input().split()) A count = 0 0 count flag = False False flag count += 1 1 count
N = int(raw_input())
A = map(int, raw_input().split())
count = 0
flag = True
while flag:
    flag = False
    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 = True
            count += 1
print " ".join(map(str, A))
print count