N = input()
A = map(int, raw_input().split())
ans = 0
flag = True
while flag:
    flag = False
    for j in xrange(N-1, 0, -1):
        if A[j] < A[j-1]:
            ans += 1
            A[j], A[j-1] = A[j-1], A[j]
            flag = True
print ' '.join(map(str, A))
print ans N = input() N input() input A = map(int, raw_input().split()) A map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split ans = 0 ans 0 flag = True flag True while flag:
    flag = False
    for j in xrange(N-1, 0, -1):
        if A[j] < A[j-1]:
            ans += 1
            A[j], A[j-1] = A[j-1], A[j]
            flag = True flag flag = False flag False for j in xrange(N-1, 0, -1):
        if A[j] < A[j-1]:
            ans += 1
            A[j], A[j-1] = A[j-1], A[j]
            flag = True j xrange(N-1, 0, -1) xrange N-1 N 1 0 -1 if A[j] < A[j-1]:
            ans += 1
            A[j], A[j-1] = A[j-1], A[j]
            flag = True A[j] < A[j-1] A[j] A j A[j-1] A j-1 j 1 ans += 1 ans 1 A[j], A[j-1] = A[j-1], A[j] A[j] A j A[j-1] A j-1 j 1 A[j-1] A j-1 j 1 A[j] A j flag = True flag True print ' '.join(map(str, A)) ' '.join ' ' join map(str, A) map str A print flag = True True flag flag = False False flag ans += 1 1 ans A = map(int, raw_input().split()) map(int, raw_input().split()) A N = input() input() N flag = True True flag ans = 0 0 ans
N = input()
A = map(int, raw_input().split())
ans = 0
flag = True
while flag:
    flag = False
    for j in xrange(N-1, 0, -1):
        if A[j] < A[j-1]:
            ans += 1
            A[j], A[j-1] = A[j-1], A[j]
            flag = True
print ' '.join(map(str, A))
print ans