If the value at that index is negative then we need to find the index of the value just greater than - D [ i ]
else : NEW_LINE INDENT k = bisect . bisect_right ( D , - D [ i ] , 0 , len ( D ) ) NEW_LINE total += n - k NEW_LINE DEDENT return total NEW_LINE