Traverse in the map to sum up the ( occurrences - 1 ) of duplicate elements
foreach ( KeyValuePair < int , int > entry in mp ) { if ( entry . Value > 1 ) { count += ( entry . Value - 1 ) ; } } return count ; }