N = int(raw_input())
A = map(int, raw_input().split())
count = 0
flag = True
while flag:
    flag = False
    for i in xrange(N-1, 0, -1):
        if A[i-1] > A[i]:
            A[i-1], A[i] = A[i], A[i-1]
            count+=1
            flag = True
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 i in xrange(N-1, 0, -1):
        if A[i-1] > A[i]:
            A[i-1], A[i] = A[i], A[i-1]
            count+=1
            flag = True flag flag = False flag False for i in xrange(N-1, 0, -1):
        if A[i-1] > A[i]:
            A[i-1], A[i] = A[i], A[i-1]
            count+=1
            flag = True i xrange(N-1, 0, -1) xrange N-1 N 1 0 -1 if A[i-1] > A[i]:
            A[i-1], A[i] = A[i], A[i-1]
            count+=1
            flag = True A[i-1] > A[i] A[i-1] A i-1 i 1 A[i] A i A[i-1], A[i] = A[i], A[i-1] A[i-1] A i-1 i 1 A[i] A i A[i] A i A[i-1] A i-1 i 1 count+=1 count 1 flag = True flag True print ' '.join(map(str, A)) ' '.join ' ' join map(str, A) map str A print A = map(int, raw_input().split()) map(int, raw_input().split()) A flag = True True flag flag = True True flag count+=1 1 count N = int(raw_input()) int(raw_input()) N count = 0 0 count flag = False False flag
N = int(raw_input())
A = map(int, raw_input().split())
count = 0
flag = True
while flag:
    flag = False
    for i in xrange(N-1, 0, -1):
        if A[i-1] > A[i]:
            A[i-1], A[i] = A[i], A[i-1]
            count+=1
            flag = True
print ' '.join(map(str, A))
print count