import itertools
import operator
yoba = lambda s: sum(itertools.starmap(operator.gt, itertools.combinations(s, 2)))
seqs = (
(1, 2, 5, 3, 4, 7, 6),
(4, 3, 2, 1),
tuple(reversed(range(10))),
(0, 1, 2, 3, 4),
(4, 3, 2, 1, 0, 1),
)
for seq in seqs:
print(yoba(seq))
aW1wb3J0IGl0ZXJ0b29scwppbXBvcnQgb3BlcmF0b3IKCgp5b2JhID0gbGFtYmRhIHM6IHN1bShpdGVydG9vbHMuc3Rhcm1hcChvcGVyYXRvci5ndCwgaXRlcnRvb2xzLmNvbWJpbmF0aW9ucyhzLCAyKSkpCgpzZXFzID0gKAoJKDEsIDIsIDUsIDMsIDQsIDcsIDYpLAoJKDQsIDMsIDIsIDEpLAoJdHVwbGUocmV2ZXJzZWQocmFuZ2UoMTApKSksCgkoMCwgMSwgMiwgMywgNCksCgkoNCwgMywgMiwgMSwgMCwgMSksCikKZm9yIHNlcSBpbiBzZXFzOgoJCglwcmludCh5b2JhKHNlcSkpCg==