n = int(raw_input())
a = map(int,raw_input().split(' '))

nswap = 0
for i in range(n):
    for j in reversed(range(i+1,n)):
        if a[j] < a[j-1]:
            a[j],a[j-1]=a[j-1],a[j]
            nswap+=1

print ' '.join([str(v) for v in a])
print nswap 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 ' ' nswap = 0 nswap 0 for i in range(n):
    for j in reversed(range(i+1,n)):
        if a[j] < a[j-1]:
            a[j],a[j-1]=a[j-1],a[j]
            nswap+=1 i range(n) range n for j in reversed(range(i+1,n)):
        if a[j] < a[j-1]:
            a[j],a[j-1]=a[j-1],a[j]
            nswap+=1 j reversed(range(i+1,n)) reversed range(i+1,n) range i+1 i 1 n if a[j] < a[j-1]:
            a[j],a[j-1]=a[j-1],a[j]
            nswap+=1 a[j] < a[j-1] a[j] a j a[j-1] a j-1 j 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 nswap+=1 nswap 1 print str(v) for v in a for v in a v a for v in a str(v) str v ' '.join([str(v) for v in a]) ' '.join ' ' join [str(v) for v in a] print nswap = 0 0 nswap n = int(raw_input()) int(raw_input()) n a = map(int,raw_input().split(' ')) map(int,raw_input().split(' ')) a nswap+=1 1 nswap
n = int(raw_input())
a = map(int,raw_input().split(' '))

nswap = 0
for i in range(n):
    for j in reversed(range(i+1,n)):
        if a[j] < a[j-1]:
            a[j],a[j-1]=a[j-1],a[j]
            nswap+=1

print ' '.join([str(v) for v in a])
print nswap