_, vs, c = input(), list(map(int, input().split())), 0
for i in range(len(vs)):
    for j in range(len(vs)-1, i, -1):
        if vs[j] < vs[j-1]:
            vs[j], vs[j-1] = vs[j-1], vs[j]
            c += 1
print(' '.join(map(str, vs)))
print(c) _, vs, c = input(), list(map(int, input().split())), 0 _ input() input vs list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c 0 for i in range(len(vs)):
    for j in range(len(vs)-1, i, -1):
        if vs[j] < vs[j-1]:
            vs[j], vs[j-1] = vs[j-1], vs[j]
            c += 1 i range(len(vs)) range len(vs) len vs for j in range(len(vs)-1, i, -1):
        if vs[j] < vs[j-1]:
            vs[j], vs[j-1] = vs[j-1], vs[j]
            c += 1 j range(len(vs)-1, i, -1) range len(vs)-1 len(vs) len vs 1 i -1 if vs[j] < vs[j-1]:
            vs[j], vs[j-1] = vs[j-1], vs[j]
            c += 1 vs[j] < vs[j-1] vs[j] vs j vs[j-1] vs j-1 j 1 vs[j], vs[j-1] = vs[j-1], vs[j] vs[j] vs j vs[j-1] vs j-1 j 1 vs[j-1] vs j-1 j 1 vs[j] vs j c += 1 c 1 print(' '.join(map(str, vs))) print ' '.join(map(str, vs)) ' '.join ' ' join map(str, vs) map str vs print(c) print c c += 1 1 c c = input(), list(map(int, input().split())), 0 0 c vs, c = input(), list(map(int, input().split())), 0 list(map(int, input().split())) vs _, vs, c = input(), list(map(int, input().split())), 0 input() _
_, vs, c = input(), list(map(int, input().split())), 0
for i in range(len(vs)):
    for j in range(len(vs)-1, i, -1):
        if vs[j] < vs[j-1]:
            vs[j], vs[j-1] = vs[j-1], vs[j]
            c += 1
print(' '.join(map(str, vs)))
print(c)