Just use the map container in STL.
#include<iostream>
#include<map>
#include<math.h>
using namespace std;
int main()
{
int n;
cin >> n;
map<int, int> m;
int v;
for (int i = 0; i < n; i++)
{
cin >> v;
m[abs(v)]++;
}
int counter = 0;
for (map<int, int>::iterator it = m.begin(); it != m.end(); it++)
{
if (it->second > 1) counter++;
}
cout << counter << endl;
system("pause");
return 0;
}