Can anyone help in pointing out the mistake in my implementation of https://www.codechef.com/MAY18B/problems/RD19

I am getting WA. Here is my implementation:

```
#include <iostream>
using namespace std;
int gcd(int a, int b)
{
int dividend = a>=b?a:b;
int divisor = a<=b?a:b;
while(divisor != 0)
{
int remainder = dividend % divisor;
dividend = divisor;
divisor = remainder;
}
return dividend;
}
int main()
{
int t;
cin>>t;
while(t --)
{
int n;
cin>>n;
int a[n];
for(int i=1;i<=n;i++)
cin>>a*;
int c = 0;
int ans = a[1];
for(int i=2;i<=n;i++)
{
ans = gcd(ans,a*);
if(ans != 1)
c++;
}
if(c == n-1)
cout<<"-1"<<endl;
else
cout<<c<<endl;
}
return 0;
}
```