will finish countSmallerElementsOnRight later to find simpler solution