Help me in solving TRIO problem

My issue

in my approach i started traversing through the list and find a,b,c by index l[i] and l[i+1]. if 2*b==a+c i increased the count
print count
it is not passing the testcases

My code

# cook your dish here
t=int(input())
for i in range(t):
    n=int(input())
    d=0
    l=[int(i) for i in input().split()]
    for i in range(1,len(l)-1):
        a=l[i]-l[i+1]
        b=l[i]+l[i+1]
        c=l[i]*l[i+1]
        if 2*b==a+c:
            d+=1 
    print(d)
        

Problem Link: Freedom Practice Coding Problem - CodeChef

@kesav07
plzz refer my c++ code for better understanding

#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];
	    map<long long int,long long int> mp;
	    long long int ans=0;
	    for(int i=0;i<n;i++)
	    {
	        cin>>a[i];
	        
	        if(a[i]!=1)
	        {
	            long long int ch=a[i]*3LL;
	            if(ch%(a[i]-1)==0)
	            {
	                ans+=mp[ch/(a[i]-1)];
	            }
	        }
	        mp[a[i]]++;
	    }
	    cout<<ans<<endl;
	}
	return 0;
}