n = input()
lst = map(int, raw_input().split())
flag = True
cnt=0
while flag:
    flag = False
    for j in range(n-1,0,-1):
        if lst[j] < lst[j-1]:
            tmp=lst[j-1]
            lst[j-1] = lst[j]
            lst[j] = tmp
            flag = True
            cnt+=1

print " ".join(map(str, (lst)))
print cnt n = input() n input() input lst = map(int, raw_input().split()) lst map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split flag = True flag True cnt=0 cnt 0 while flag:
    flag = False
    for j in range(n-1,0,-1):
        if lst[j] < lst[j-1]:
            tmp=lst[j-1]
            lst[j-1] = lst[j]
            lst[j] = tmp
            flag = True
            cnt+=1 flag flag = False flag False for j in range(n-1,0,-1):
        if lst[j] < lst[j-1]:
            tmp=lst[j-1]
            lst[j-1] = lst[j]
            lst[j] = tmp
            flag = True
            cnt+=1 j range(n-1,0,-1) range n-1 n 1 0 -1 if lst[j] < lst[j-1]:
            tmp=lst[j-1]
            lst[j-1] = lst[j]
            lst[j] = tmp
            flag = True
            cnt+=1 lst[j] < lst[j-1] lst[j] lst j lst[j-1] lst j-1 j 1 tmp=lst[j-1] tmp lst[j-1] lst j-1 j 1 lst[j-1] = lst[j] lst[j-1] lst j-1 j 1 lst[j] lst j lst[j] = tmp lst[j] lst j tmp flag = True flag True cnt+=1 cnt 1 print " ".join(map(str, (lst))) " ".join " " join map(str, (lst)) map str lst print cnt+=1 1 cnt flag = True True flag flag = False False flag cnt=0 0 cnt lst = map(int, raw_input().split()) map(int, raw_input().split()) lst n = input() input() n tmp=lst[j-1] lst[j-1] tmp flag = True True flag
n = input()
lst = map(int, raw_input().split())
flag = True
cnt=0
while flag:
    flag = False
    for j in range(n-1,0,-1):
        if lst[j] < lst[j-1]:
            tmp=lst[j-1]
            lst[j-1] = lst[j]
            lst[j] = tmp
            flag = True
            cnt+=1

print " ".join(map(str, (lst)))
print cnt