a=int(input()) b=list(map(int,input().split())) c=0 for d in range(a): for e in range(0, a-d-1): if b[e] > b[e+1] : b[e], b[e+1] = b[e+1], b[e] c=c+1 print(c)
结果:AC30%