3 test cases are not passing
what is the wrong approach in my code and what would be the right approach
#include
#include
using namespace std;
int main ()
{
int n,count=0,i;
cin>>n;
int a[n];
for(i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
for(i=1;i<n;i++)
{
if(a[i]==a[i-1])
swap(a[i],a[i+1]);
}
for(i=1;i<n;i++)
{
if(a[i]>a[i-1])
count++;
}
cout<<count;
return 0;
}