Function to return the count of valid pairs
def countPairs ( a , n ) : NEW_LINE INDENT count = 0 NEW_LINE m = dict ( ) NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE DEDENT DEDENT