Help me in solving OPTMFLP18 problem

My issue

cook your dish here

for _ in range(int(input())):
n=int(input())
l=list(map(int,input().split()))

# a=0
c=0
z=0
for i in range(n):
    if l[i]%2==0:
        c+=(n-z)
        z+=1

if z!=n:
    c+=(n-z)
print(c)

whats wring with my approach or which testcase will it fail

My code

# cook your dish here
for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    
    # a=0
    c=0
    z=0
    for i in range(n):
        if l[i]%2==0:
            c+=(n-z)
            z+=1

    if z!=n:
        c+=(n-z)
    print(c)
    
            

Problem Link: Optimal Flip Practice Coding Problem - CodeChef

@unfettered_one
here plzz refer my c++ code for better understanding of the logic

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    long long int n;
	    cin>>n;
	    long long int a[n];
	    long long int ch=0;
	    map<long long int,long long int> mp;
	    for(long long int i=0;i<n;i++)
	    {
	        cin>>a[i];
	        if(a[i]%2==0)
	        ch=i+1;
	        mp[i]=ch;
	    }
	    long long int ans=0,fans=0,cnt=0,cnt1=0;
	    
	    for(long long int i=0;i<n;i++)
	    {
	        if(a[i]%2==0)
	        {
	            ans+=(i+1LL);
	        }
	        else
	        ans+=mp[i];
	    }
	    fans=ans;
	    for(long long int i=n-1;i>=0;i--)
	    {
	        if(a[i]%2)
	        {
	            cnt++;
	            cnt1+=mp[i];
	            long long int tmans=ans-cnt1;
	            tmans=tmans+((i+1)*cnt);
	            fans=max(fans,tmans);
	        }
	        else
	        {
	            cnt=0;
	            cnt1=0;
	        }
	    }
	    cout<<fans<<endl;
	}
	return 0;
}