<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described.
<END_TASK>
<USER_TASK:>
Description:
Count of index pairs with equal elements in an array
Python3 program to count of index pairs with equal elements in an array . ; Return the number of pairs with equal values . ; Finding frequency of each number . ; Calculating pairs of each value . ; Driver Code

<ASSISTANT_TASK:>
Python Code:
import math as mt 
 def countPairs(arr , n ) : 
	 mp = dict() 
 for i in range(n ) : 
	 if arr[i ] in mp . keys() : 
	 mp[arr[i ] ] += 1 
  else : 
	 mp[arr[i ] ] = 1 
   ans = 0 
 for it in mp : 
	 count = mp[it ] 
 ans +=(count *(count - 1 ) ) // 2 
  return ans 
  arr =[1 , 1 , 2 ] 
 n = len(arr ) 
 print(countPairs(arr , n ) ) 

<END_TASK>
