For the given question I have come up with the following code. But it doesn't seem to solve the problem. Please have a look and suggest changes.
#include <iostream>
#include <limits.h>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int maxim=INT_MIN;
for(int i=0;i<n;i++)
{
int sum=0;
for(int j=i;j<n;j++)
{
sum+=arr[j];
if (sum%2==0){
int len=n-i;
maxim=max(maxim,len);
}
}
}
cout<<maxim;
return 0;
}