nums in ascending order.i at 0 and j at 1.cnt to 0.j is less than the length of nums, do the following:
a. If nums[j] is less than or equal to nums[i], increment j.
b. If nums[j] is greater than nums[i], increment both i and j, and increment cnt.cnt as the result.