CFS2002-HELP

Why my code is not working for these problem???
question-CodeChef: Practical coding for everyone
my solution----CodeChef: Practical coding for everyone
#include< iostream >
using namespace std;

int main() {
int t;
cin>>t;
while(t - -)
{
int n,i,j,k,countev=0,countod=0;
cin>>n;
long int sum=0,greatsum=0;
int a[n];
for(i=1;i<=n;i++)
cin>>a[i];
for(i=1;i<(n-1);i++)
{
countev=1;
countod=1;
sum=0;
if(a[i]%2==0)
{
for(j=i+1;j<=n;j++)
{
if(a[j]%2==0)
countev++;
if(a[i]==a[j]&&(countev)%2==0&&(j-i)>1)
{
for(k=i+1;k<=(j-1);k++)
{
sum=sum+a[k];
}
}
else
break;
}
}
if(a[i]%2!=0)
{
for(j=i+1;j<=n;j++)
{
if(a[j]%2!=0)
countod++;
if(a[i]==a[j]&&(countod)%2!=0&&(j-i)>1)
{
for(k=i+1;k<=(j-1);k++)
{
sum=sum+a[k];
}
}
else
break;
}
}
if(sum>greatsum)
greatsum=sum;
}
cout<<greatsum<<‘\n’;
}
// your code goes here
return 0;
}
plzz suggest what are the " fault’s " present in this :point_up_2:

Please provide links to the question.And your submission or format your code with ``` before and after your code.