can anybody plz tell why i am getting wrong answer in this question
#include <iostream>
#include <cmath>
using namespace std;
int main() {int t;
cin>>t;
while(t--){
long int i,n,x=0,y=0,max=0;
cin>>n;
long int no[n]={0};
long int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
if (a[i]>max)
{
max=a[i];
}
}
for (i=0;i<n;i++)
{
if(max==a[i])
{
no[x]=i;
x++;
}
}
if(x==1)
{
cout<<n/2<<endl;
}
else
{
long int diff[x-1];
for(i=0;i<x-1;i++)
{
diff[i]=no[i+1]-no[i];
}
max=0;
for(i=0;i<x-1;i++)
{
if (diff[i]>max)
{
max=diff[i];
}
}max=max-1;
long int top=n/2-1;
if (max>top){
cout<<"0"<<endl;
}
else
{
cout<<top-max<<endl;
}
}}
return 0;
}