input: Write a function to count array elements having modular inverse under given prime number p equal to itself.
  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):
      count = 0
      for num in arr:
          if (num * num) % p == 1:
              count += 1
      return count