元の並び順を変えないで再帰するならこうだな。

Prelude> let count [] = 0; count [_] = 0; count (x:y:rest) = 1 + length rest + count (other:lts) + count ges where (pv, other) = if x < y then (y, x) else (x, y); (lts, ges) = List.partition (<pv) rest
Prelude> count [2, 4, 8, 1, 6, 5, 2, 7, 3, 7]
21