Can anyone tell me why i am getting RE in this code

#include <bits/stdc++.h>
using namespace std;
int gcdarray(vector<int>& arr,int idx){
  if(idx == arr.size()-1){
    return arr[idx];
  }
  int a= arr[idx];
  int b = gcdarray(arr,idx+1);
  return __gcd(a,b);
}

int main() {
int t;
cin>>t;
while (t--)
{
  int d;
  cin>>d;
  vector<int> a(d,0);
  for( int i=1;i<=d;i++) cin>>a[i];
    int maxgcd = gcdarray(a,0);
    int v=0;
    for(int i=1;i<=d;i++){

    
    if(a[i]==maxgcd){
      v++;
    }
    }
    cout<<d-v<<endl;
  }
  
	return 0;
}