input: Write a function that counts the elements in an array that have a modular inverse equal to the element itself under a specified prime number p.
  assert modular_inverse([ 1, 6, 4, 5 ], 4, 7) == 2
  assert modular_inverse([1, 3, 8, 12, 12], 5, 13) == 3
  assert modular_inverse([2, 3, 4, 5], 4, 6) == 1
output: def modular_inverse(arr, n, p):
      def mod_inv(x, p):
          for i in range(1, p):
              if (x * i) % p == 1:
                  return i
          return None
      
      count = 0
      for x in arr:
          if mod_inv(x, p) == x:
              count += 1
      return count