Why it doesnt work with arrays

my code is:
for(int i=0;i<n;i++)
{
int x;
cin>>x;
a[x}++;
}
int y= *max_element(a,a+n);
int c= INT_MIN;
int k=0;
for(int i=0;i<n;i++)
{
if(a[i]<c)
{
c=a[i];
k=i;
}
}
cout<<k<<endl;

wats wrong with this thanks in advace

hey this doubt is posted in wrong question kindly ignore

@the.shubham.sri,
Then mark the doubt resolved.