#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <iomanip>
#include <bitset>
using namespace std;
#define pi pair<int ,int>
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand (time(NULL));
	int test = 1;
	//cin >> test;
	while (test--)
	{
		int n;
		cin >> n;
		map <long long , int> mp1, mp2;
		vector <int> a(n+1);
		vector <long long> preSum(n+1);
		long long res = 0;
		for (int i = 1 ; i <= n ; i++)
		{
			cin >> a[i];
			if (i % 2 == 1)
			{
				preSum[i] = preSum[i-1] + a[i];
			}
			else
			{
				preSum[i] = preSum[i-1] - a[i];
			}
			if (preSum[i] == 0)
			{
				res++;
				res += mp1[0];
			}
			else
			{
				if (i % 2 == 1)
				{
					res += mp1[preSum[i]];
				}
				else
				{
					res += mp2[-preSum[i]];
				}
			}
			mp1[preSum[i]]++;
			mp2[-preSum[i]]++;
		}
		cout <<res;
	}
}




#include<bits/stdc++.h>
#define ll long long
#define fori(i,j,n) for(ll i=(ll)j;i<(ll)n;++i)
#define forr(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);--i)
#define all(x) x.begin(), x.end()
#define mp(i, j) make_pair(i, j)
#define pb(i) push_back(i)
#define pii pair<int,int> 
#define vi vector<ll>
#define vb vector<bool>
#define vii vector<vector<ll> >
using namespace std;

const int mod=998244353;
const int maxn=INT_MAX;

template<class T> T gcd(T a,T b){ while(a!=0){ T tmp=a; a=b%a; b=tmp;} return b;}
vb sieve(int n){ vb prime(n+1, true); for(int i=2;i*i<=n;i++){ if(prime[i]){ for(int j=i*i;j<=n;j+=i) prime[j]=false; }} return prime;}
vi noOfDivisors(int n){ vi div(n+1, 0); div[1]=1; fori(i, 2, n+1) div[i]=2; fori(i, 2, n+1){for(int j=2*i;j<=n;j+=i) div[j]++;} return div;}
vi divisors(ll n){vi div;for(ll i=1;i*i<=n;i++){ if(n%i==0) { div.pb(i); if(n/i!=i) div.pb(n/i); }} return div;}
ll max(ll a, ll b){ if(a>b) return a; return b;}
ll min(ll a, ll b){ if(a<b) return a; return b;}
ll addmod(ll a, ll b){ return (a%mod + b%mod)%mod;}
ll mulmod(ll a, ll b){ return (a%mod * b%mod)%mod;}
ll powmod(ll a, ll b){ll ans=1;while(b!=0){ans=mulmod(ans, a);b--;}return ans%mod;}

int main(){
	
	#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	cin.tie(0);
    ios_base::sync_with_stdio(false);
    int t=1;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        fori(i, 0, n) cin>>a[i];

        vector<pii> ans;
        int cur=0;
        fori(i, 0, n*n){
            int flag=0;
            fori(j, 0, n-1){
                if(cur%2==0 && j%2==0 && a[j]>a[j+1]) {
                    swap(a[j], a[j+1]);
                    ans.pb(mp(j+1, j+2));
                    flag=1;
                    cur=1-cur;
                    //break;
                }
                else if(cur%2==1 && j%2==1 && a[j]>a[j+1]) {
                    swap(a[j], a[j+1]);
                    ans.pb(mp(j+1, j+2));
                    flag=1;
                    cur=1-cur;
                    //break;
                }
            }
            if(flag==0){
                int flag2=0;
                fori(k, 0, n-1){
                    if(a[k]>a[k+1]) flag2=1;
                }
                if(flag2==0) break;

                if(cur%2==0) {
                    swap(a[0], a[1]);
                    ans.pb(mp(1, 2));
                    cur=1-cur;
                }
                else {
                    swap(a[1], a[2]);
                    ans.pb(mp(2,3));
                    cur=1-cur;
                }
            }
            //cout<<ans[ans.size()-1].first<<" ";
        }	
    	cout<<ans.size()<<'\n';
        //if(ans.size()!=0) cout<<'\n';
        fori(i, 0, ans.size()){
            cout<<ans[i].first;
            cout<<" ";
        }
        cout<<'\n';
        
    }
    return 0;
}




































