c = int(input())
s = input().split()
count = 0
for j in range(c):
    for i in range(c-1,j,-1):
        if int(s[i]) < int(s[i-1]):
            s[i],s[i-1] = s[i-1],s[i]
            count += 1
print(" ".join(s))
print(count) c = int(input()) c int(input()) int input() input s = input().split() s input().split() ().split () input split count = 0 count 0 for j in range(c):
    for i in range(c-1,j,-1):
        if int(s[i]) < int(s[i-1]):
            s[i],s[i-1] = s[i-1],s[i]
            count += 1 j range(c) range c for i in range(c-1,j,-1):
        if int(s[i]) < int(s[i-1]):
            s[i],s[i-1] = s[i-1],s[i]
            count += 1 i range(c-1,j,-1) range c-1 c 1 j -1 if int(s[i]) < int(s[i-1]):
            s[i],s[i-1] = s[i-1],s[i]
            count += 1 int(s[i]) < int(s[i-1]) int(s[i]) int s[i] s i int(s[i-1]) int s[i-1] s i-1 i 1 s[i],s[i-1] = s[i-1],s[i] s[i] s i s[i-1] s i-1 i 1 s[i-1] s i-1 i 1 s[i] s i count += 1 count 1 print(" ".join(s)) print " ".join(s) " ".join " " join s print(count) print count c = int(input()) int(input()) c s = input().split() input().split() s count = 0 0 count count += 1 1 count
c = int(input())
s = input().split()
count = 0
for j in range(c):
    for i in range(c-1,j,-1):
        if int(s[i]) < int(s[i-1]):
            s[i],s[i-1] = s[i-1],s[i]
            count += 1
print(" ".join(s))
print(count)