n = int(input())
s = [ i for i in input().split()]
flag = True
cnt = 0
while flag:
    flag = False
    for i in range(n-1):
        if int(s[i]) > int(s[i+1]):
            s[i],s[i+1] = s[i+1],s[i]
            flag = True
            cnt += 1
print(' '.join(s))
print(cnt)
 n = int(input()) n int(input()) int input() input i for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() i s = [ i for i in input().split()] s [ i for i in input().split()] flag = True flag True cnt = 0 cnt 0 while flag:
    flag = False
    for i in range(n-1):
        if int(s[i]) > int(s[i+1]):
            s[i],s[i+1] = s[i+1],s[i]
            flag = True
            cnt += 1 flag flag = False flag False for i in range(n-1):
        if int(s[i]) > int(s[i+1]):
            s[i],s[i+1] = s[i+1],s[i]
            flag = True
            cnt += 1 i range(n-1) range n-1 n 1 if int(s[i]) > int(s[i+1]):
            s[i],s[i+1] = s[i+1],s[i]
            flag = True
            cnt += 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 flag = True flag True cnt += 1 cnt 1 print(' '.join(s)) print ' '.join(s) ' '.join ' ' join s print(cnt) print cnt flag = False False flag flag = True True flag flag = True True flag cnt += 1 1 cnt n = int(input()) int(input()) n s = [ i for i in input().split()] [ i for i in input().split()] s cnt = 0 0 cnt
n = int(input())
s = [ i for i in input().split()]
flag = True
cnt = 0
while flag:
    flag = False
    for i in range(n-1):
        if int(s[i]) > int(s[i+1]):
            s[i],s[i+1] = s[i+1],s[i]
            flag = True
            cnt += 1
print(' '.join(s))
print(cnt)

