Using the map template to solve the problem.

```
int singleNumber(int A[], int n) {
map<int, int> countMap;
int num = 0;
if (n <= 0)
return -1;
for (int i = 0; i< n; i++)
{
if (countMap.find(A[i]) != countMap.end())
countMap[A[i]] += 1;
else
countMap[A[i]] = 1;;
}
for (int i = 0; i < n; i++)
{
if (countMap[A[i]] == 1)
return A[i];
}
}
```