def count_inversion(sequence):
count = 0
"""
Count inversions in a sequence of numbers
"""
for i in range(len(sequence)):
for j in range(i+1, len(sequence)):
if sequence[i] > sequence[j]:
count +=1
return count
ZGVmIGNvdW50X2ludmVyc2lvbihzZXF1ZW5jZSk6CiAgICBjb3VudCA9IDAKICAgICIiIgogICAgICAgIENvdW50IGludmVyc2lvbnMgaW4gYSBzZXF1ZW5jZSBvZiBudW1iZXJzCiAgICAiIiIKICAgIGZvciBpIGluIHJhbmdlKGxlbihzZXF1ZW5jZSkpOgogICAgICAgIGZvciBqIGluIHJhbmdlKGkrMSwgbGVuKHNlcXVlbmNlKSk6CiAgICAgICAgICAgIGlmIHNlcXVlbmNlW2ldID4gc2VxdWVuY2Vbal06CiAgICAgICAgICAgICAgICBjb3VudCArPTEKICAgIHJldHVybiBjb3VudA==