for example list of 7 elements {1,2,1,3,2,4,1} there are two pairs (1,1) and (2,2) with the rest being unmatched, how do I return the amount of pairs? (need to write my code under def
def sockMerchant(n, ar):
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input().strip())
ar = list(map(int, input().rstrip().split()))
result = sockMerchant(n, ar)
fptr.write(str(result) + '\n')
fptr.close()