#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int main()
{
	long long t,a[maxn],n,flag,i,x,y,b[10],xx,yy;
	cin>>t;
	while(t--)
	{
		cin>>n;
		memset(b,0,sizeof(b));
		int ans=1;
		flag=0,x=0,y=0;
		for(i=1;i<=n;i++)
		{
			cin>>a[i];
			if(a[i]>0)
				y++;
		}
		sort(a+1,a+n+1);
		if(y==0)
		{
			for(i=n;i>=n-4;i--)
				ans*=a[i];
			printf("%lld\n",ans);
			continue;
		}
		for(i=n-1;i>=1;i-=2)
		{
			if(a[i]>0&&a[i-1]>0)
			{
				b[flag]=a[i]*a[i-1];
				flag++;
			}
			else break;
			if(flag==2) break;
		}
		for(i=1;i<=n-1;i+=2)
		{
			if(a[i]<0&&a[i+1]<0)
			{
				b[flag]=a[i]*a[i+1];
				flag++;
			}
			else break;
			if(flag==4) break;
		}
		if(flag==1||flag==0)
			ans=0;
		else if(flag==2)
			ans=b[0]*b[1]*a[n];
		else if(flag==3)
		{
			sort(b,b+3);
			ans=a[n]*b[2]*b[1];
		}
		else
		{
			sort(b,b+4);
			ans=a[n]*b[3]*b[2];
		}
		printf("%lld\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int main()
{
	map<int ,int>mp;
	int t,a[maxn],n,flag,i,x,y,b[10],xx,yy;
	cin>>t;
	while(t--)
	{
		cin>>n;
		memset(b,0,sizeof(b));
		int ans=1;
		flag=0,x=0,y=0;
		for(i=1;i<=n;i++)
		{
			cin>>a[i];
			if(a[i]>0)
				y++;
		}
		sort(a+1,a+n+1);
		if(y==0)
		{
			for(i=n;i>=n-4;i--)
				ans*=a[i];
		}
		for(i=n-1;i>=1;i-=2)
		{
			if(a[i]>0&&a[i-1]>0)
			{
				b[flag]=a[i]*a[i-1];
				flag++;
			}
			else break;
			if(flag==2) break;
		}
		for(i=1;i<=n-1;i+=2)
		{
			if(a[i]<0&&a[i+1]<0)
			{
				b[flag]=a[i]*a[i+1];
				flag++;
			}
			else break;
			if(flag==4) break;
		}
		if(flag==0) puts("0");
		else if(flag==1)
		{
				for(i=n;i>=n-4;i--)
				ans*=a[i];
		}
		else if(flag==2) ans=b[0]*b[1]*a[n];
		else if(flag==3)
		{
			b[3]=-1;
			sort(b,b+4);
			ans=a[n]*b[3]*b[2];
		}
		else
		{
			sort(b,b+4);
			ans=a[n]*b[3]*b[2];
		}
		printf("%d\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int main()
{
	long long t,a[maxn],n,flag,i,x,y,b[10],xx,yy;
	cin>>t;
	while(t--)
	{
		cin>>n;
		memset(b,0,sizeof(b));
		long long ans=1;
		flag=0,x=0,y=0;
		for(i=1;i<=n;i++)
		{
			cin>>a[i];
			if(a[i]>0)
				y++;
		}
		sort(a+1,a+n+1);
		if(y==0)
		{
			for(i=n;i>=n-4;i--)
				ans*=a[i];
			printf("%lld\n",ans);
			continue;
		}
		for(i=n-1;i>=1;i-=2)
		{
			if(a[i]>0&&a[i-1]>0)
			{
				b[flag]=a[i]*a[i-1];
				flag++;
			}
			else break;
			if(flag==2) break;
		}
		for(i=1;i<=n-1;i+=2)
		{
			if(a[i]<0&&a[i+1]<0)
			{
				b[flag]=a[i]*a[i+1];
				flag++;
			}
			else break;
			if(flag==4) break;
		}
		if(flag==1||flag==0)
			ans=0;
		else if(flag==2)
			ans=b[0]*b[1]*a[n];
		else if(flag==3)
		{
			sort(b,b+3);
			ans=a[n]*b[2]*b[1];
		}
		else
		{
			sort(b,b+4);
			ans=a[n]*b[3]*b[2];
		}
		printf("%lld\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int main()
{
	map<int ,int>mp;
	int t,a[maxn],n,flag,i,x,y,b[10],xx,yy;
	cin>>t;
	while(t--)
	{
		cin>>n;
		memset(b,0,sizeof(b));
		int ans=1;
		flag=0,x=0,y=0;
		for(i=1;i<=n;i++)
		{
			cin>>a[i];
			if(a[i]>0)
				y++;
		}
		sort(a+1,a+n+1);
		if(y==0)
		{
			for(i=n;i>=n-4;i--)
				ans*=a[i];
			printf("%d\n",ans);
			continue;
		}
		for(i=n-1;i>=1;i-=2)
		{
			if(a[i]>0&&a[i-1]>0)
			{
				b[flag]=a[i]*a[i-1];
				flag++;
			}
			else break;
			if(flag==2) break;
		}
		for(i=1;i<=n-1;i+=2)
		{
			if(a[i]<0&&a[i+1]<0)
			{
				b[flag]=a[i]*a[i+1];
				flag++;
			}
			else break;
			if(flag==4) break;
		}
		if(flag==0) puts("0");
		else if(flag==1)
		{
				for(i=n;i>=n-4;i--)
				ans*=a[i];
		}
		else if(flag==2) ans=b[0]*b[1]*a[n];
		else if(flag==3)
		{
			b[3]=-1;
			sort(b,b+4);
			ans=a[n]*b[3]*b[2];
		}
		else
		{
			sort(b,b+4);
			ans=a[n]*b[3]*b[2];
		}
		printf("%d\n",ans);
	}
}


#include <bits/stdc++.h>
#define ll long long
#define pi acos(-1.00)
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
//
//ll f[1500];
//
//ll MOD=1e9+7;
//ll ans=1;
//
//ll binpower(ll fac, ll p)
//{
//    ll res=1;
//    while(p)
//    {
//        if(p%2) res=(res*fac)%MOD;
//
//        p/=2;
//        fac=(fac*fac)%MOD;
//    }
//    return res;
//}
//
//void inv(ll a,ll b)
//{
//    ans=(ans*binpower(a,MOD-2))%MOD;
////    ans=(ans*binpower(f[b],MOD-2))%MOD;
////    ans=(ans*binpower(f[a-b],MOD-2))%MOD;
//
//}

//vector<ll>adj[100005],centroid,subtree_size(100005),ans;
//
//void find_centroid(ll node,ll parent,ll node_num)
//{
//    subtree_size[node]=1;
//    bool is_centroid=true;
//
//    for(auto next_node: adj[node])
//    if(next_node!=parent){
//        find_centroid(next_node,node,node_num);
//        subtree_size[node]+=subtree_size[next_node];
//        if(subtree_size[next_node] > node_num/2) is_centroid=false;
//    }
//
//    if(node_num-subtree_size[node] > node_num/2) is_centroid=false;
//    if(is_centroid) centroid.push_back(node);
//}
//
//void dfs(ll n1,ll n2)
//{
//    for(auto v: adj[n1]){
//        if(v!=n2){
////            cout << v << " " << n1 << "\n";
//            dfs(v,n1);
//        }
//    }
//    if(subtree_size[n1]==1) ans.push_back(n1);
//}

int main()
{
    fastio;
    ll i,j,t,n,m,u,v,k,N,R,x,y;

    cin>>t;

    while(t--)
    {
        cin>>n;

        vector<pair<ll,ll> >vp;
        ll p=0,neg=0,ze=0;
        for(i=0; i<n; i++)
        {
            cin>>x;
            vp.push_back({abs(x),x});
            if(x>0) p++;
            else if(x==0) ze++;
        }
        sort(vp.begin(),vp.end(),greater<>());

        if(p==0 && ze!=0) cout << "0\n";
        else if(p==0 && ze==0) cout << vp[0].second*vp[1].second*vp[2].second*vp[3].second*vp[4].second<< "\n";
        else{
            ll ans=vp[0].second*vp[1].second*vp[2].second*vp[3].second*vp[4].second;
            ll res=vp[0].second*vp[1].second*vp[2].second*vp[3].second*vp[4].second;
            if(ans<0 && n>5){
                for(i=4;i>=0;i--)
                    if(vp[i].second<0) break;
                for(j=4;j>=0;j--)
                    if(vp[j].second>0) break;

                for(y=5;y<vp.size();y++)
                    if(vp[y].second<0) break;
                for(x=5;x<vp.size();x++)
                    if(vp[x].second>0) break;
                if(x<n){
                    ans/=vp[i].second;
                    ans*=vp[x].second;
                }
                if(y<n){
                    res/=vp[j].second;
                    res*=vp[y].second;
                }

            }
            if(ze)
                cout << max(max(ans,res),0ll) << "\n";
            else cout << max(ans,res) << "\n";
        }
    }

}


//#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<deque>
#include<map>
#include<set>
#include<queue>
#include<optional>
#include<assert.h>
#include<tuple>

using namespace std;

int max_my(vector<int>& nums) {
	int maxim = 0;
	int ind = 0;
	for (size_t i = 1; i < nums.size(); ++i) {
		if (nums[i] - nums[i] % (i + 1) >= maxim) {
			maxim = nums[i] - nums[i] % (i + 1);
			ind = i;
		}
	}
	return ind;
}

void solve() {
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int& i : nums) {
		cin >> i;
	}
	int total = 0;
	for (size_t i = 0; i < nums.size(); ++i) {
		total += nums[i];
	}
	if (total % n > 0) {
		cout << -1 << "\n";
		return;
	}
	bool all_eq = true;
	for (size_t i = 1; i < n; ++i) {
		if (nums[i - 1] != nums[i]) {
			all_eq = false;
		}
	}
	if (all_eq) {
		cout << 0 << "\n";
		return;
	}

	int used = 0;
	int free = 3;
	vector<vector<int>> answer;
	for (int i = 1; i < n; ++i) {
		if (nums[i] != 0 && nums[i] % (i + 1) == 0) {
			answer.push_back({ i + 1,1,nums[i] / (i + 1) });
			nums[0] += nums[i];
			nums[i] = 0;
		}
	}
	set<pair<int, int>> to_take;
	for (int i = 1; i < n; ++i) {
		if ((i + 1) - nums[i] % (i + 1) <= nums[0]) {
			answer.push_back({ 1,i + 1,(i + 1) - nums[i] % (i + 1) });
			answer.push_back({ i + 1,1,(nums[i]-1) / (i + 1) +1 });
			nums[0] += nums[i];
			nums[i] = 0;
		}
		else {
			to_take.emplace((i + 1) - nums[i] % (i + 1), i);
		}
	}
	while (!to_take.empty()) {
		if (to_take.begin()->first <= nums[0]) {
			answer.push_back({ 1,to_take.begin()->second + 1,to_take.begin()->first });
			answer.push_back({ to_take.begin()->second + 1,1,(nums[to_take.begin()->second] - 1) / (to_take.begin()->second + 1) + 1 });
			nums[0] += nums[to_take.begin()->second];
			nums[to_take.begin()->second] = 0;
			to_take.erase(to_take.begin());
		}
		else if (free){
			int ind = max_my(nums);
			answer.push_back({ ind+1,1,nums[ind]/(ind + 1) });
			nums[0] += nums[ind] / (ind + 1) * (ind + 1);
		}
		else {
			assert(false);
			cout << -1 << "\n";
		}
	}
	for (int i = 1; i < n; ++i) {
		answer.push_back({ 1,i + 1,total/n});
	}
	cout << answer.size() << "\n";
	for (vector<int>& v : answer) {
		for (int i : v) {
			cout << i << " ";
		}
		cout << "\n";
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--)solve();
	return 0;
}


//#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<deque>
#include<map>
#include<set>
#include<queue>
#include<optional>
#include<assert.h>
#include<tuple>

using namespace std;

int max_my(vector<int>& nums) {
	int maxim = 0;
	int ind = 0;
	for (size_t i = 1; i < nums.size(); ++i) {
		if (nums[i] - nums[i] % (i + 1) >= maxim) {
			maxim = nums[i] - nums[i] % (i + 1);
			ind = i;
		}
	}
	return ind;
}

void solve() {
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int& i : nums) {
		cin >> i;
	}
	int total = 0;
	for (size_t i = 0; i < nums.size(); ++i) {
		total += nums[i];
	}
	if (total % n > 0) {
		cout << -1 << "\n";
		return;
	}
	bool all_eq = true;
	for (size_t i = 1; i < n; ++i) {
		if (nums[i - 1] != nums[i]) {
			all_eq = false;
		}
	}
	if (all_eq) {
		cout << 0 << "\n";
		return;
	}

	int used = 0;
	int free = 3;
	vector<vector<int>> answer;
	for (int i = 1; i < n; ++i) {
		if (nums[i] != 0 && nums[i] % (i + 1) == 0) {
			answer.push_back({ i + 1,1,nums[i] / (i + 1) });
			nums[0] += nums[i];
			nums[i] = 0;
		}
	}
	set<pair<int, int>> to_take;
	for (int i = 1; i < n; ++i) {
		if ((i + 1) - nums[i] % (i + 1) <= nums[0]) {
			answer.push_back({ 1,i + 1,(i + 1) - nums[i] % (i + 1) });
			answer.push_back({ i + 1,1,(nums[i]-1) / (i + 1) +1 });
			nums[0] += nums[i];
			nums[i] = 0;
		}
		else {
			to_take.emplace((i + 1) - nums[i] % (i + 1), i);
		}
	}
	while (!to_take.empty()) {
		if (to_take.begin()->first <= nums[0]) {
			answer.push_back({ 1,to_take.begin()->second + 1,to_take.begin()->first });
			answer.push_back({ to_take.begin()->second + 1,1,(nums[to_take.begin()->second] - 1) / (to_take.begin()->second + 1) + 1 });
			nums[0] += nums[to_take.begin()->second];
			nums[to_take.begin()->second] = 0;
			to_take.erase(to_take.begin());
		}
		else if (free){
			--free;
			int ind = max_my(nums);
			answer.push_back({ ind+1,1,nums[ind]/(ind + 1) });
			nums[0] += nums[ind] / (ind + 1) * (ind + 1);
		}
		else {
			assert(false);
			cout << -1 << "\n";
		}
	}
	for (int i = 1; i < n; ++i) {
		answer.push_back({ 1,i + 1,total/n});
	}
	cout << answer.size() << "\n";
	for (vector<int>& v : answer) {
		for (int i : v) {
			cout << i << " ";
		}
		cout << "\n";
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--)solve();
	return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iomanip>
#include <float.h>
#define _USE_MATH_DEFINES
#include <math.h>

#define ll long long

#define FOR(i,a,b)        for(ll i=(a);i<(b);i++)
#define REP(i,n)        FOR(i,0,n)
#define SORT(v)            sort((v).begin(),(v).end())
#define UN(v)            SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)            memset(a,b,sizeof a)
#define pb                push_back

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

using namespace std;

//#define N 1000009
ll denom = 998244353; //1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=denom; for(;b;b>>=1){if(b&1)res=res*a%denom;a=a*a%denom;}return res;}
ll n;

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    ll t; cin >> t;
    while (t-- > 0) {
        cin >> n;
        vector<ll> a(n); REP(i, n) cin >> a[i];
        ll sum = 0; REP(i, n) sum += a[i];
        if (sum%n != 0) {
            cout << -1 << endl;
            continue;
        }
        ll target = sum/n;
        vector<pair<pair<ll, ll>, ll>> v;
        FOR(i, 1, n) {
            if (a[i] >= i+1) {
                ll k = a[i]/(i+1);
                a[0] += k*(i+1);
                a[i] -= k*(i+1);
                v.push_back({{i+1, 1}, k});
            }
        }
        bool possible = true;
        FOR(i, 1, n) {
            if (a[i] > target) {
                if (a[i]+a[0] < i+1) {possible = false; break;}
                ll x = i+1-a[i];
                v.push_back({{1, i+1}, x});
                v.push_back({{i+1, 1}, 1});
            }
        }
        if (!possible) {
            cout << -1 << endl;
            continue;
        }
        FOR(i, 1, n) {
            if (a[i] < target) {
                v.push_back({{1, i+1}, target-a[i]});
            }
        }
        cout << v.size() << endl;
        REP(i, v.size()) {
            cout << v[i].first.first << " " << v[i].first.second << " " << v[i].second << endl;
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iomanip>
#include <float.h>
#define _USE_MATH_DEFINES
#include <math.h>

#define ll long long

#define FOR(i,a,b)        for(ll i=(a);i<(b);i++)
#define REP(i,n)        FOR(i,0,n)
#define SORT(v)            sort((v).begin(),(v).end())
#define UN(v)            SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)            memset(a,b,sizeof a)
#define pb                push_back

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

using namespace std;

//#define N 1000009
ll denom = 998244353; //1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=denom; for(;b;b>>=1){if(b&1)res=res*a%denom;a=a*a%denom;}return res;}
ll n;

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    ll t; cin >> t;
    while (t-- > 0) {
        cin >> n;
        vector<ll> a(n); REP(i, n) cin >> a[i];
        ll sum = 0; REP(i, n) sum += a[i];
        if (sum%n != 0) {
            cout << -1 << endl;
            continue;
        }
        ll target = sum/n;
        vector<pair<pair<ll, ll>, ll>> v;

        FOR(i, 1, n) {
            if (a[i] >= i+1) {
                ll k = a[i]/(i+1);
                ll f = a[i]%(i+1);
                f = i+1 - f;
                if (a[0] >= f) {
                    v.push_back({{1, i+1}, f});
                    v.push_back({{i+1, 1}, k+1});
                    a[0] += (k+1)*(i+1);
                    a[i] = 0;
                } else {
                    a[0] += k*(i+1);
                    a[i] -= k*(i+1);
                    v.push_back({{i+1, 1}, k});
                }
            }
        }

        vector<pair<ll, ll>> p;
        FOR(i,1,n) {
            if (a[i] > target) {
                p.push_back({i+1-a[i], i});
            }
        }
        SORT(p);
        bool possible = true;
        ll extra = a[0];
        for (auto b : p) {
            if (b.first > extra) {
                possible = false;
                break;
            }
            extra += a[b.second];
        }
        if (!possible) {
            cout << -1 << endl;
            continue;
        }

        for (auto b : p) {
            ll i = b.second;
            if (a[i] > target) {
                ll x = i+1-a[i];
                a[0] += a[i];
                a[i] = 0;
                v.push_back({{1, i+1}, x});
                v.push_back({{i+1, 1}, 1});
            }
        }

        FOR(i, 1, n) {
            if (a[i] < target) {
                v.push_back({{1, i+1}, target-a[i]});
            }
        }
        cout << v.size() << endl;
        REP(i, v.size()) {
            cout << v[i].first.first << " " << v[i].first.second << " " << v[i].second << endl;
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iomanip>
#include <float.h>
#define _USE_MATH_DEFINES
#include <math.h>

#define ll long long

#define FOR(i,a,b)        for(ll i=(a);i<(b);i++)
#define REP(i,n)        FOR(i,0,n)
#define SORT(v)            sort((v).begin(),(v).end())
#define UN(v)            SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)            memset(a,b,sizeof a)
#define pb                push_back

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

using namespace std;

//#define N 1000009
ll denom = 998244353; //1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=denom; for(;b;b>>=1){if(b&1)res=res*a%denom;a=a*a%denom;}return res;}
ll n;

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    ll t; cin >> t;
    while (t-- > 0) {
        cin >> n;
        vector<ll> a(n); REP(i, n) cin >> a[i];
        ll sum = 0; REP(i, n) sum += a[i];
        if (sum%n != 0) {
            cout << -1 << endl;
            continue;
        }
        ll target = sum/n;
        vector<pair<pair<ll, ll>, ll>> v;

        FOR(i, 1, n) {
            if (a[i] >= i+1) {
                ll k = a[i]/(i+1);
                if (a[i]%(i+1) == 0) {
                    v.push_back({{i+1, 1}, k});
                    a[0] += a[i];
                } else {
                    ll f = (k+1)*(i+1)-a[i];
                    v.push_back({{1, i+1}, f});
                    v.push_back({{i+1, 1}, k+1});
                }
            }
        }

        FOR(i, 1, n) v.push_back({{1, i+1}, target});
        cout << v.size() << endl;
        REP(i, v.size()) cout << v[i].first.first << " " << v[i].first.second << " " << v[i].second << endl;
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iomanip>
#include <float.h>
#define _USE_MATH_DEFINES
#include <math.h>

#define ll long long

#define FOR(i,a,b)        for(ll i=(a);i<(b);i++)
#define REP(i,n)        FOR(i,0,n)
#define SORT(v)            sort((v).begin(),(v).end())
#define UN(v)            SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)            memset(a,b,sizeof a)
#define pb                push_back

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

using namespace std;

//#define N 1000009
ll denom = 998244353; //1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=denom; for(;b;b>>=1){if(b&1)res=res*a%denom;a=a*a%denom;}return res;}
ll n;

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    ll t; cin >> t;
    while (t-- > 0) {
        cin >> n;
        vector<ll> a(n); REP(i, n) cin >> a[i];
        ll sum = 0; REP(i, n) sum += a[i];
        if (sum%n != 0) {
            cout << -1 << endl;
            continue;
        }
        ll target = sum/n;
        vector<pair<pair<ll, ll>, ll>> v;

        FOR(i, 1, n) {
            ll k = a[i]/(i+1);
            if (a[i]%(i+1) == 0) {
                v.push_back({{i+1, 1}, k});
                a[0] += a[i];
            } else {
                ll f = (k+1)*(i+1)-a[i];
                v.push_back({{1, i+1}, f});
                v.push_back({{i+1, 1}, k+1});
            }
        }

        FOR(i, 1, n) v.push_back({{1, i+1}, target});
        cout << v.size() << endl;
        REP(i, v.size()) cout << v[i].first.first << " " << v[i].first.second << " " << v[i].second << endl;
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iomanip>
#include <float.h>
#define _USE_MATH_DEFINES
#include <math.h>

#define ll long long

#define FOR(i,a,b)        for(ll i=(a);i<(b);i++)
#define REP(i,n)        FOR(i,0,n)
#define SORT(v)            sort((v).begin(),(v).end())
#define UN(v)            SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)            memset(a,b,sizeof a)
#define pb                push_back

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

using namespace std;

//#define N 1000009
ll denom = 998244353; //1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=denom; for(;b;b>>=1){if(b&1)res=res*a%denom;a=a*a%denom;}return res;}
ll n;

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    ll t; cin >> t;
    while (t-- > 0) {
        cin >> n;
        vector<ll> a(n); REP(i, n) cin >> a[i];
        ll sum = 0; REP(i, n) sum += a[i];
        if (sum%n != 0) {
            cout << -1 << endl;
            continue;
        }
        ll target = sum/n;
        vector<pair<pair<ll, ll>, ll>> v;

        FOR(i, 1, n) {
            if (a[i] >= i+1) {
                ll k = a[i]/(i+1);
                a[0] += k*(i+1);
                a[i] -= k*(i+1);
                v.push_back({{i+1, 1}, k});
            }
        }

        vector<pair<ll, ll>> p;
        FOR(i,1,n) {
            if (a[i] > target) {
                p.push_back({i+1-a[i], i});
            }
        }
        SORT(p);
        bool possible = true;
        ll extra = a[0];
        for (auto b : p) {
            if (b.first > extra) {
                possible = false;
                break;
            }
            extra += a[b.second];
        }
        if (!possible) {
            cout << -1 << endl;
            continue;
        }

        for (auto b : p) {
            ll i = b.second;
            if (a[i] > target) {
                ll x = i+1-a[i];
                a[0] += a[i];
                a[i] = 0;
                v.push_back({{1, i+1}, x});
                v.push_back({{i+1, 1}, 1});
            }
        }

        if (!possible) {
            cout << -1 << endl;
            continue;
        }
        FOR(i, 1, n) {
            if (a[i] < target) {
                v.push_back({{1, i+1}, target-a[i]});
            }
        }
        cout << v.size() << endl;
        REP(i, v.size()) {
            cout << v[i].first.first << " " << v[i].first.second << " " << v[i].second << endl;
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iomanip>
#include <float.h>
#define _USE_MATH_DEFINES
#include <math.h>

#define ll long long

#define FOR(i,a,b)        for(ll i=(a);i<(b);i++)
#define REP(i,n)        FOR(i,0,n)
#define SORT(v)            sort((v).begin(),(v).end())
#define UN(v)            SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)            memset(a,b,sizeof a)
#define pb                push_back

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

using namespace std;

//#define N 1000009
ll denom = 998244353; //1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=denom; for(;b;b>>=1){if(b&1)res=res*a%denom;a=a*a%denom;}return res;}
ll n;

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    ll t; cin >> t;
    while (t-- > 0) {
        cin >> n;
        vector<ll> a(n); REP(i, n) cin >> a[i];
        ll sum = 0; REP(i, n) sum += a[i];
        if (sum%n != 0) {
            cout << -1 << endl;
            continue;
        }
        ll target = sum/n;
        vector<pair<pair<ll, ll>, ll>> v;
        FOR(i, 1, n) {
            if (a[i] >= i+1) {
                ll k = a[i]/(i+1);
                a[0] += k*(i+1);
                a[i] -= k*(i+1);
                v.push_back({{i+1, 1}, k});
            }
        }
        bool possible = true;
        FOR(i, 1, n) {
            if (a[i] > target) {
                if (a[i]+a[0] < i+1) {possible = false; break;}
                ll x = i+1-a[i];
                a[0] += a[i];
                a[i] = 0;
                v.push_back({{1, i+1}, x});
                v.push_back({{i+1, 1}, 1});
            }
        }
        if (!possible) {
            cout << -1 << endl;
            continue;
        }
        FOR(i, 1, n) {
            if (a[i] < target) {
                v.push_back({{1, i+1}, target-a[i]});
            }
        }
        cout << v.size() << endl;
        REP(i, v.size()) {
            cout << v[i].first.first << " " << v[i].first.second << " " << v[i].second << endl;
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	for (int test = 0; test < t; ++test) {
		int res = 0;
		int n;
		cin >> n;
		vector<int> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];

		int sum = accumulate(begin(v), end(v), 0);
		if (sum % n != 0) cout << "-1\n";
		else {
			vector<vector<int>> res;
			int d = sum / n;
			for (int i = 1; i < n; ++i) {
				int r = v[i] % (i + 1);
				int m = v[i] / (i + 1);
				if (m > 0) {
					res.push_back({ i + 1, 1, m });
					v[0] += m * (i + 1);
					v[i] -= m * (i + 1);
				}
			}

			vector<pair<int,int>> pos;
			for (int i = 1; i < n; ++i) {
				if (v[i] > d) {
					pos.emplace_back(i + 1 + d - v[i], i);
				}
			}
			sort(begin(pos), end(pos));
			reverse(begin(pos), end(pos));

			for (auto& p : pos) {
				int i = p.second;
				res.push_back({ 1, i + 1, i + 1 + d - v[i] });
				v[0] -= i + 1 + d - v[i];
				if (v[0] < 0) { cout << "-1\n";  break; }
				v[i] += i + 1 + d - v[i];
				res.push_back({ i + 1, 1, 1 });
				v[i] -= i + 1;
				v[0] += i + 1;
			}
			if (v[0] >= 0) {
				for (int i = 1; i < n; ++i) {
					if (v[i] < d) {
						res.push_back({ 1, i + 1, d - v[i] });
						v[0] -= d - v[i];
						v[i] += d - v[i];
					}
				}
				cout << res.size() << endl;
				for (auto& a : res) {
					cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
				}
			}
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	for (int test = 0; test < t; ++test) {
		int res = 0;
		int n;
		cin >> n;
		vector<int> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];

		int sum = accumulate(begin(v), end(v), 0);
		if (sum % n != 0) cout << "-1\n";
		else {
			vector<vector<int>> res;
			int d = sum / n;
			for (int i = 1; i < n; ++i) {
				int r = v[i] % (i + 1);
				int m = v[i] / (i + 1);
				res.push_back({ i + 1, 1, m });
				v[0] += m * (i + 1);
				v[i] -= m * (i + 1);
			}

			for (int i = 1; i < n; ++i)
				if (v[i] > d) {
					res.push_back({ 1, i + 1, i + 1 + d - v[i] });
					v[0] -= i + 1 + d - v[i];
					if (v[0] < 0) { cout << "-1\n";  break; }
					v[i] += i + 1 + d - v[i];
					res.push_back({ i + 1, 1, 1 });
					v[i] -= i + 1;
					v[0] += i + 1;
				}
			if (v[0] >= 0) {
				for (int i = 1; i < n; ++i) {
					if (v[i] < d) {
						res.push_back({ 1, i + 1, d - v[i] });
						v[0] -= d - v[i];
						v[i] += d - v[i];
					}
				}
			}
			cout << res.size() << endl;
			for (auto& a : res) {
				cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
			}
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	for (int test = 0; test < t; ++test) {
		int res = 0;
		int n;
		cin >> n;
		vector<int> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];

		int sum = accumulate(begin(v), end(v), 0);
		if (sum % n != 0) cout << "-1\n";
		else {
			vector<vector<int>> res;
			int d = sum / n;
			for (int i = 1; i < n; ++i) {
				int r = v[i] % (i + 1);
				int m = v[i] / (i + 1);
				res.push_back({ i + 1, 1, m });
				v[0] += m * (i + 1);
				v[i] -= m * (i + 1);
			}

			vector<pair<int,int>> pos;
			for (int i = 1; i < n; ++i) {
				if (v[i] > d) {
					pos.emplace_back(i + 1 + d - v[i], i);
				}
			}
			sort(begin(pos), end(pos));
			reverse(begin(pos), end(pos));

			for (auto& p : pos) {
				int i = p.second;
				res.push_back({ 1, i + 1, i + 1 + d - v[i] });
				v[0] -= i + 1 + d - v[i];
				if (v[0] < 0) { cout << "-1\n";  break; }
				v[i] += i + 1 + d - v[i];
				res.push_back({ i + 1, 1, 1 });
				v[i] -= i + 1;
				v[0] += i + 1;
			}
			if (v[0] >= 0) {
				for (int i = 1; i < n; ++i) {
					if (v[i] < d) {
						res.push_back({ 1, i + 1, d - v[i] });
						v[0] -= d - v[i];
						v[i] += d - v[i];
					}
				}
			}
			cout << res.size() << endl;
			for (auto& a : res) {
				cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
			}
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	for (int test = 0; test < t; ++test) {
		int res = 0;
		int n;
		cin >> n;
		vector<int> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];

		int sum = accumulate(begin(v), end(v), 0);
		if (sum % n != 0) cout << "-1\n";
		else {
			vector<vector<int>> res;
			int d = sum / n;
			for (int i = 1; i < n; ++i) {
				int r = v[i] % (i + 1);
				int m = v[i] / (i + 1);
				if (m > 0) {
					res.push_back({ i + 1, 1, m });
					v[0] += m * (i + 1);
					v[i] -= m * (i + 1);
				}
			}

			vector<pair<int,int>> pos;
			for (int i = 1; i < n; ++i) {
				if (v[i] > d) {
					pos.emplace_back(i + 1 + d - v[i], i);
				}
			}
			sort(begin(pos), end(pos));
			reverse(begin(pos), end(pos));

			for (auto& p : pos) {
				int i = p.second;
				res.push_back({ 1, i + 1, i + 1 + d - v[i] });
				v[0] -= i + 1 + d - v[i];
				//if (v[0] < 0) { cout << "-1\n";  break; }
				v[i] += i + 1 + d - v[i];
				res.push_back({ i + 1, 1, 1 });
				v[i] -= i + 1;
				v[0] += i + 1;
			}
			if (v[0] >= 0) {
				for (int i = 1; i < n; ++i) {
					if (v[i] < d) {
						res.push_back({ 1, i + 1, d - v[i] });
						v[0] -= d - v[i];
						v[i] += d - v[i];
					}
				}
				cout << res.size() << endl;
				for (auto& a : res) {
					cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
				}
			}
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	for (int test = 0; test < t; ++test) {
		int res = 0;
		int n;
		cin >> n;
		vector<int> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];

		int sum = accumulate(begin(v), end(v), 0);
		if (sum % n != 0) cout << "-1\n";
		else {
			vector<vector<int>> res;
			int d = sum / n;
			for (int i = 1; i < n; ++i) {
				int r = v[i] % (i + 1);
				if (r > 0) {
					res.push_back({ 1, i + 1, (i+1) - r });
					v[0] -= (i + 1) - r;
					v[i] += (i + 1) - r;
				}
				int q = v[i] / (i + 1);
				res.push_back({ i + 1, 1, q });
				v[0] += q * (i + 1);
				v[i] -= q * (i + 1);
			}

			for (int i = 1; i < n; ++i) {
				res.push_back({1, i+1, d});
			}

			cout << res.size() << endl;
			for (auto& a : res) {
				cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
			}
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	for (int test = 0; test < t; ++test) {
		int res = 0;
		int n;
		cin >> n;
		vector<int> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];

		int sum = accumulate(begin(v), end(v), 0);
		if (sum % n != 0) cout << "-1\n";
		else {
			vector<vector<int>> res;
			int d = sum / n;
			for (int i = 1; i < n; ++i) {
				int r = v[i] % (i + 1);
				int m = v[i] / (i + 1);
				res.push_back({ i + 1, 1, m });
				v[0] += m * (i + 1);
				v[i] -= m * (i + 1);
			}

			vector<pair<int,int>> pos;
			for (int i = 1; i < n; ++i) {
				if (v[i] > d) {
					pos.emplace_back(i + 1 + d - v[i], i);
				}
			}
			sort(begin(pos), end(pos));
			reverse(begin(pos), end(pos));

			for (auto& p : pos) {
				int i = p.second;
				res.push_back({ 1, i + 1, i + 1 + d - v[i] });
				v[0] -= i + 1 + d - v[i];
				if (v[0] < 0) { cout << "-1\n";  break; }
				v[i] += i + 1 + d - v[i];
				res.push_back({ i + 1, 1, 1 });
				v[i] -= i + 1;
				v[0] += i + 1;
			}
			if (v[0] >= 0) {
				for (int i = 1; i < n; ++i) {
					if (v[i] < d) {
						res.push_back({ 1, i + 1, d - v[i] });
						v[0] -= d - v[i];
						v[i] += d - v[i];
					}
				}
				cout << res.size() << endl;
				for (auto& a : res) {
					cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
				}
			}
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	for (int test = 0; test < t; ++test) {
		int res = 0;
		int n;
		cin >> n;
		vector<long long> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];

		int sum = accumulate(begin(v), end(v), 0);
		if (sum % n != 0) cout << "-1\n";
		else {
			vector<vector<long long>> res;
			int d = sum / n;
			for (int i = 1; i < n; ++i) {
				int r = v[i] % (i + 1);
				int m = v[i] / (i + 1);
				if (m > 0) {
					res.push_back({ i + 1, 1, m });
					v[0] += m * (i + 1);
					v[i] -= m * (i + 1);
				}
			}

			vector<pair<long long,int>> pos;
			for (int i = 1; i < n; ++i) {
				if (v[i] > d) {
					pos.emplace_back(i + 1 + d - v[i], i);
				}
			}
			sort(begin(pos), end(pos));
			reverse(begin(pos), end(pos));

			for (auto& p : pos) {
				int i = p.second;
				res.push_back({ 1, i + 1, i + 1 + d - v[i] });
				v[0] -= i + 1 + d - v[i];
//				if (v[0] < 0) { cout << "-1\n";  break; }
				v[i] += i + 1 + d - v[i];
				res.push_back({ i + 1, 1, 1 });
				v[i] -= i + 1;
				v[0] += i + 1;
			}
			if (v[0] >= 0) {
				for (int i = 1; i < n; ++i) {
					if (v[i] < d) {
						res.push_back({ 1, i + 1, d - v[i] });
						v[0] -= d - v[i];
						v[i] += d - v[i];
					}
				}
				cout << res.size() << endl;
				for (auto& a : res) {
					cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
				}
			}
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	for (int test = 0; test < t; ++test) {
		int res = 0;
		int n;
		cin >> n;
		vector<long long> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];

		int sum = accumulate(begin(v), end(v), 0);
		if (sum % n != 0) cout << "-1\n";
		else {
			vector<vector<int>> res;
			int d = sum / n;
			for (int i = 1; i < n; ++i) {
				int r = v[i] % (i + 1);
				int m = v[i] / (i + 1);
				if (m > 0) {
					res.push_back({ i + 1, 1, m });
					v[0] += m * (i + 1);
					v[i] -= m * (i + 1);
				}
			}

			vector<pair<long long,int>> pos;
			for (int i = 1; i < n; ++i) {
				if (v[i] > d) {
					pos.emplace_back(i + 1 + d - v[i], i);
				}
			}
			sort(begin(pos), end(pos));
			reverse(begin(pos), end(pos));

			for (auto& p : pos) {
				int i = p.second;
				res.push_back({ 1, i + 1, i + 1 + d - v[i] });
				v[0] -= i + 1 + d - v[i];
				if (v[0] < 0) { cout << "-1\n";  break; }
				v[i] += i + 1 + d - v[i];
				res.push_back({ i + 1, 1, 1 });
				v[i] -= i + 1;
				v[0] += i + 1;
			}
			if (v[0] >= 0) {
				for (int i = 1; i < n; ++i) {
					if (v[i] < d) {
						res.push_back({ 1, i + 1, d - v[i] });
						v[0] -= d - v[i];
						v[i] += d - v[i];
					}
				}
				cout << res.size() << endl;
				for (auto& a : res) {
					cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
				}
			}
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	for (int test = 0; test < t; ++test) {
		int res = 0;
		int n;
		cin >> n;
		vector<int> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];

		int sum = accumulate(begin(v), end(v), 0);
		if (sum % n != 0) cout << "-1\n";
		else {
			vector<vector<int>> res;
			int d = sum / n;
			for (int i = 1; i < n; ++i) {
				int r = v[i] % (i + 1);
				int m = v[i] / (i + 1);
				if (m > 0) {
					res.push_back({ i + 1, 1, m });
					v[0] += m * (i + 1);
					v[i] -= m * (i + 1);
				}
			}

			vector<pair<int,int>> pos;
			vector<int> was(n, 0);
			for (int i = 1; i < n; ++i) {
				if (v[i] > d) {
					pos.emplace_back(i + 1 + d - v[i], i);
					was[i] = 1;
				}
			}
			sort(begin(pos), end(pos));
			reverse(begin(pos), end(pos));
			for (auto& p : pos) {
				int i = p.second;
				res.push_back({ 1, i + 1, i + 1 + d - v[i] });
				v[0] -= i + 1 + d - v[i];
				if (v[0] < 0) { cout << "-1\n";  break; }
				v[i] += i + 1 + d - v[i];
				res.push_back({ i + 1, 1, 1 });
				v[i] -= i + 1;
				v[0] += i + 1;
			}
			if (v[0] >= 0) {
				for (int i = 1; i < n; ++i) {
					if (v[i] < d && was[i] == 0) {
						res.push_back({ 1, i + 1, d - v[i] });
						v[0] -= d - v[i];
						v[i] += d - v[i];
					}
				}
				cout << res.size() << endl;
				for (auto& a : res) {
					cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
				}
			}
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	for (int test = 0; test < t; ++test) {
		int res = 0;
		int n;
		cin >> n;
		vector<long long> v(n);
		for (int i = 0; i < n; ++i)
			cin >> v[i];

		int sum = accumulate(begin(v), end(v), 0);
		if (sum % n != 0) cout << "-1\n";
		else {
			vector<vector<long long>> res;
			int d = sum / n;
			for (int i = 1; i < n; ++i) {
				int r = v[i] % (i + 1);
				int m = v[i] / (i + 1);
				if (m > 0) {
					res.push_back({ i + 1, 1, m });
					v[0] += m * (i + 1);
					v[i] -= m * (i + 1);
				}
			}

			vector<pair<long long,int>> pos;
			for (int i = 1; i < n; ++i) {
				if (v[i] > d) {
					pos.emplace_back(i + 1 + d - v[i], i);
				}
			}
			sort(begin(pos), end(pos));
			reverse(begin(pos), end(pos));

			for (auto& p : pos) {
				int i = p.second;
				res.push_back({ 1, i + 1, i + 1 + d - v[i] });
				v[0] -= i + 1 + d - v[i];
				if (v[0] < 0) { cout << "-1\n";  break; }
				v[i] += i + 1 + d - v[i];
				res.push_back({ i + 1, 1, 1 });
				v[i] -= i + 1;
				v[0] += i + 1;
			}
			if (v[0] >= 0) {
				for (int i = 1; i < n; ++i) {
					if (v[i] < d) {
						res.push_back({ 1, i + 1, d - v[i] });
						v[0] -= d - v[i];
						v[i] += d - v[i];
					}
				}
				cout << res.size() << endl;
				for (auto& a : res) {
					cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
				}
			}
		}
	}
	return 0;
}


#include<iostream>
using namespace std;
int t,n;
#define ll long long int
const int MAXN = 1e4+10;
struct node{
    int i,j,x;
}e[MAXN*3];
ll a[MAXN];
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        ll sum=0;int ans=0;
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        if(sum%n!=0){
            printf("-1\n");continue;
        }
        else{
            for(int i=2;i<=n;i++){
                if(a[i]%i==0){
                    e[++ans].i=i;e[ans].j=1;e[ans].x=a[i]/i;
                    a[1]+=a[i];a[i]=0;
                }
                else{
                    int k=a[i]/i;
	                e[++ans].i=1;e[ans].j=i;e[ans].x=i*(k+1)-a[i];
	                a[i]+=i*(k+1)-a[i];a[1]-=i*(k+1)-a[i];
                    e[++ans].i=i;e[ans].j=1;e[ans].x=a[i]/i;
                    a[1]+=a[i];a[i]=0;
                }
            }
            int k=sum/n;
            for(int i=2;i<=n;i++){
                e[++ans].i=1;e[ans].j=i;e[ans].x=k;
            }
        }
        printf("%d\n",ans);
        for(int i=1;i<=ans;i++){
            printf("%d %d %d\n",e[i].i,e[i].j,e[i].x);
        }
    }
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>
#include <chrono>
#include <assert.h>      // std::rand, std::srand
#include <string.h>

using namespace std;

//ifstream cin("input.in");
//ofstream cout("output.out");

typedef long long LL;
typedef long double LD;
typedef vector<vector<int>> vvi;
const int INF = 0x3f3f3f3f;
const long long INF64 = 3e18 + 1;

//typedef __uint128_t u128;

const char invdir[]{'L', 'U', 'R', 'D'};
const char dir[]{'R', 'D', 'L', 'U'};

const int dx[]{0, 1, 0, -1};
const int dy[]{1, 0, -1, 0};

unsigned get_seed(){
    unsigned seed = chrono::system_clock::now().time_since_epoch().count();
    return seed;
}

/*
struct Point{
    int x, y, id;
};

bool cw(Point a, Point b, Point c) {
    return 1LL*(1LL*(a.y - b.y) * (c.x - b.x) -
            1LL*(a.x - b.x) * (c.y - b.y)) > 0;
}
*/
const int MOD = 998244353;
const int NMAX = 10555;

int a[NMAX];

struct node{
  int i, j, x;
};

int solve(){
  int n;
  cin >> n;
  int sum = 0;
  for(int i = 1; i <= n; ++i){
    cin >> a[i];
    sum += a[i];
  }

  if(n == 1){
    cout << 0 << "\n";
    return 0;
  }

  if(sum % n){
    cout << -1 << "\n";
    return 0;
  }

  vector<node> queries;
  int min_all = INF;
  /*
  for(int i = 2; i <= n; ++i){
    if(a[i]/i > 0){
      queries.push_back({i, 1, a[i]/i});
      a[1] += (a[i] / i) * i;
      a[i] %= i;
      break;
    }
  }
  if(a[1] == 0){
    // never happens
  }
  */
  // in a[1] at least one el
  for(int i = 2; i <= n; ++i){
    if(a[i] % i){
      // fix the residue
      queries.push_back({1, i, i - (a[i] % i)});
      a[1] -= i - (a[i] % i);
      a[i] += i - (a[i] % i);
      queries.push_back({i, 1, a[i]/i});
      a[1] += (a[i] / i)*i;
      a[i] -= (a[i] / i)*i;
    }else{
      queries.push_back({i, 1, a[i]/i});
      a[1] += (a[i] / i)*i;
      a[i] -= (a[i] / i)*i;
    }
  }

  int dx = sum / n;
  for(int i = 2; i <= n; ++i){
    queries.push_back({1, i, dx});
    a[i] += dx;
    a[1] -= dx;
  }

  cout << queries.size() << "\n";
  for(auto el: queries){
    cout << el.i << " " << el.j << " " << el.x << "\n";
  }

  return 0;
}

int main() {
    cout << setprecision(16);
    cin.tie(0);
    std::ios_base::sync_with_stdio(0);
    int T = 1;
    //sieve();

    //auto rng = mt19937{get_seed()};
    cin >> T;

    //sieve();
    int i = 1;
    while(T--){
        i++;
        /*
        if(i != 26 && i != 25 && i != 27)
            continue;
            */
        //cout << "Case #" << i << ": ";

        solve();
        //cout << "\n";
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>
#include <chrono>
#include <assert.h>      // std::rand, std::srand
#include <string.h>

using namespace std;

//ifstream cin("input.in");
//ofstream cout("output.out");

typedef long long LL;
typedef long double LD;
typedef vector<vector<int>> vvi;
const int INF = 0x3f3f3f3f;
const long long INF64 = 3e18 + 1;

//typedef __uint128_t u128;

const char invdir[]{'L', 'U', 'R', 'D'};
const char dir[]{'R', 'D', 'L', 'U'};

const int dx[]{0, 1, 0, -1};
const int dy[]{1, 0, -1, 0};

unsigned get_seed(){
    unsigned seed = chrono::system_clock::now().time_since_epoch().count();
    return seed;
}

/*
struct Point{
    int x, y, id;
};

bool cw(Point a, Point b, Point c) {
    return 1LL*(1LL*(a.y - b.y) * (c.x - b.x) -
            1LL*(a.x - b.x) * (c.y - b.y)) > 0;
}
*/
const int MOD = 998244353;
const int NMAX = 10555;

int a[NMAX];

struct node{
  int i, j, x;
};

int solve(){
  int n;
  cin >> n;
  int sum = 0;
  for(int i = 1; i <= n; ++i){
    cin >> a[i];
    sum += a[i];
  }

  if(n == 1){
    cout << 0 << "\n";
  }

  if(sum % n){
    cout << -1 << "\n";
    return 0;
  }

  vector<node> queries;
  int min_all = INF;
  /*
  for(int i = 2; i <= n; ++i){
    if(a[i]/i > 0){
      queries.push_back({i, 1, a[i]/i});
      a[1] += (a[i] / i) * i;
      a[i] %= i;
      break;
    }
  }
  if(a[1] == 0){
    // never happens
  }
  */
  // in a[1] at least one el
  for(int i = 2; i <= n; ++i){
    if(a[i] % i){
      // fix the residue
      queries.push_back({1, i, i - (a[i] % i)});
      a[1] -= i - (a[i] % i);
      a[i] += i - (a[i] % i);
      queries.push_back({i, 1, a[i]/i});
      a[1] += (a[i] / i)*i;
      a[i] -= (a[i] / i)*i;
    }else{
      queries.push_back({i, 1, a[i]/i});
      a[1] += (a[i] / i)*i;
      a[i] -= (a[i] / i)*i;
    }
  }

  int dx = sum / n;
  for(int i = 2; i <= n; ++i){
    queries.push_back({1, i, dx});
    a[i] += dx;
    a[1] -= dx;
  }

  cout << queries.size() << "\n";
  for(auto el: queries){
    cout << el.i << " " << el.j << " " << el.x << "\n";
  }

  return 0;
}

int main() {
    cout << setprecision(16);
    cin.tie(0);
    std::ios_base::sync_with_stdio(0);
    int T = 1;
    //sieve();

    //auto rng = mt19937{get_seed()};
    cin >> T;

    //sieve();
    int i = 1;
    while(T--){
        i++;
        /*
        if(i != 26 && i != 25 && i != 27)
            continue;
            */
        //cout << "Case #" << i << ": ";

        solve();
        //cout << "\n";
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <iostream>
#include <fstream>
#include <chrono>

using namespace std;

const int DIV = 1000000007;

void solve(int test, istream &in) {
    int n;
    in >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        in >> a[i];
        sum += a[i];
    }
    if (sum % n != 0) {
        printf("-1\n");
        return;
    }
    int mid = sum / n;
    printf("%d\n", (n - 1) * 3);
    for (int i = 1; i < n; i++) {
        int x = a[i] % (i + 1);
        if (x != 0)
            x = i + 1 - x;
        printf("%d %d %d\n", 1, i + 1, x);
        a[i] += x;
        printf("%d %d %d\n", i + 1, 1, a[i] / (i + 1));
    }
    for (int i = 1; i < n; i++) {
        printf("%d %d %d\n", 1, i + 1, mid);
    }
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
    //FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
    auto start = std::chrono::steady_clock::now();
#else
    //FILE *f = stdin;
    istream &f = cin;
#endif
    int tests;
    //tests = 1;
    f >> tests;
    for (int test = 0; test < tests; test++) {
        solve(test, f);
    }
#ifdef VLAD_LOCAL
    auto end = std::chrono::steady_clock::now();
    double seconds = (double)std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() / 1000;
    printf("%.3lf\n", seconds);
#endif
    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <array>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>
typedef long long ll;
using namespace std;

int dX1[4] = { 0, 0, -1, 1 };
int dY1[4] = { -1, 1, 0, 0 };
int dX2[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dY2[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };

const int MOD = 1000000007;
const int mxn = 2e4;
const int INF = 1e9;

int n;

int a[mxn];

int mult(int a, int b) {
	return (1LL * a * b) % MOD;
}

int add(int a, int b) {
	ll res = 0LL + a + b;
	while (res >= MOD) {
		res -= MOD;
	}
	while (res < 0) {
		res += MOD;
	}
	return res;
}

int sub(int a, int b) {
	ll res = 0LL + a - b;
	while (res >= MOD) {
		res -= MOD;
	}
	while (res < 0) {
		res += MOD;
	}
	return res;
}

int exp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	if (n == 1) {
		return x;
	}
	int ret = exp(x, n >> 1);
	if (n & 1) {
		return mult(mult(ret, ret), x);
	}
	return mult(ret, ret);
}

int main() {
	int T;
	cin >> T;
	while (T--) {
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}

		int total = 0;
		for (int i = 0; i < n; i++) {
			total += a[i];
		}

		if (total % n) {
			cout << -1 << endl;
			continue;
		}

		vector<vector<int>> ans;
		for (int i = 1; i < n; i++) {
			int v = i + 1;
			if (a[i] % v) {
				int tr = v - a[i] % v;
				ans.push_back({ 1, v, tr });
				a[0] -= tr;
				a[i] += tr;
				assert(a[0] >= 0);
				assert(a[i] >= 0);
			}
			assert(a[i] % v == 0);
			ans.push_back({ v, 1, a[i] / v });
			a[0] += a[i];
			a[i] -= a[i];
			assert(a[0] >= 0);
			assert(a[i] >= 0);
		}

		assert(a[0] == total);
		for (int i = 1; i < n; i++) {
			int v = i + 1;
			ans.push_back({ 1, v, total / n });
		}

		cout << ans.size() << endl;
		for (vector<int> op : ans) {
			cout << op[0] << ' ' << op[1] << ' ' << op[2] << endl;
		}
	}
}


#ifndef LOCAL
#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,tune=native")
#endif //LOCAL

#define _SCL_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:256000000")

#define first x
#define second y

#include <cassert>
#include <ciso646>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <array>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <complex>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <locale>
#include <numeric>
#include <regex>
#include <string>
#include <utility>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <random>
#include <memory>
#include <chrono>

#ifdef LOCAL
//#include <vld.h>
#endif //LOCAL
using namespace std;

//typedef __int128_t ll;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double ld;

#define speedup cout.tie(nullptr);cin.tie(nullptr);ios_base::sync_with_stdio(false)
#define coutdouble cout<<setprecision(20);cout<<fixed

#define all(v) (v).begin(),(v).end()
#define sz(v) (int)(v).size()

#ifdef LOCAL
mt19937 rd(57322);
#else
//mt19937 rd(57322);
mt19937 rd((uint)chrono::steady_clock::now().time_since_epoch().count());
#endif
/*------CommentInInteractive--------*/
#ifndef LOCAL
#define endl '\n'
#endif //LOCAL
/*----------------------------------*/
const int INF = 1000 * 1000 * 1000 + 322;
const ll LLINF = 2LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL + 57;
constexpr int MOD = 1000 * 1000 * 1000 + 7;
constexpr int FFT_MOD = 998244353;
const int P1E6 = 1336337;
const int P1E3 = 1009;
const ll P1E14 = 100000000000031;
const ll P1E17 = 100000000000000003;
const ld PI = acosl(-1.);//3.1415926535897932384626433832795
const ld EPS = 1e-13;
/*------------------------------------------------IO_OPERATORS---------------------------------------------*/
template<typename T, typename U> inline ostream &operator << (ostream &_out, const pair<T, U> &_p) { _out << _p.first << " " << _p.second; return _out; }
template<typename T, typename U> inline istream &operator >> (istream &_in, pair<T, U> &_p) { _in >> _p.first >> _p.second; return _in; }
template<typename T> inline ostream &operator << (ostream &_out, const vector<T> &_v) { if (_v.empty()) return _out; _out << _v.front(); for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) _out << ' ' << *_it; return _out; }
template<typename T> inline istream &operator >> (istream &_in, vector<T> &_v) { for (auto &_i : _v) _in >> _i; return _in; }
template<typename T> inline ostream &operator << (ostream &_out, const set<T> &_s) { if (_s.empty()) return _out; _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it; return _out; }
template<typename T> inline ostream &operator << (ostream &_out, const multiset<T> &_s) { if (_s.empty()) return _out; _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it; return _out; }
template<typename T> inline ostream &operator << (ostream &_out, const unordered_set<T> &_s) { if (_s.empty()) return _out; _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it; return _out; }
template<typename T> inline ostream &operator << (ostream &_out, const unordered_multiset<T> &_s) { if (_s.empty()) return _out; _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it; return _out; }
template<typename T, typename U> inline ostream &operator << (ostream &_out, const map<T, U> &_m) { if (_m.empty()) return _out; _out << "{\"" << _m.begin()->first << "\", \"" << _m.begin()->second << "\"}"; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) _out << ", { \"" << _it->first << "\", \"" << _it->second << "\"}"; return _out; }
template<typename T, typename U> inline ostream &operator << (ostream &_out, const unordered_map<T, U> &_m) { if (_m.empty()) return _out; _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) _out << ", (" << _it->first << ": " << _it->second << ')'; return _out; }
/*--------------------------------------------------IO_FILES-----------------------------------------------*/
const char * infile =
#ifdef LOCAL
"input.txt"
#else
""
#endif //LOCAL
;
const char * outfile =
#ifdef LOCAL
""
#else
""
#endif //LOCAL
;

/*-------------------------------------------------ALLOCATOR----------------------------------------------*/
//#define ALLOC_LOCAL
#ifdef ALLOC_LOCAL
const int ML_ = 1000;
char mem_[ML_ * 1024 * 1024];
size_t _ptr = 0, _magic = 21323400;
void * operator new(size_t cnt) { if (_ptr + cnt < sizeof mem_) { _ptr += cnt; return  mem_ + _ptr - cnt; } else { assert(false); _ptr = cnt + _magic; return mem_ + _magic; } }
void operator delete(void *) {}
#endif //ALLOC_LOCAL
/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) { while (b) { a %= b; swap(a, b); } return a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline int pwm(ll xx, ll pow, int MD) { if (pow < 0) { pow = pow % (MD - 1) + MD - 1; } ll mlt = 1; while (pow) { if (pow & 1) { mlt *= xx; mlt %= MD; } xx *= xx; pow >>= 1; xx %= MD; } return (int)mlt; }
inline ll gcdex(ll a, ll b, ll &x, ll &y) { if (b == 0) { x = 1; y = 0; return a; } ll xx, yy; ll gc = gcdex(b, a % b, yy, xx); x = xx; y = yy - (a / b) * xx; return gc; }
inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }
/*-----------------------------------------------------CODE------------------------------------------------*/

const int N = 3 * 100 * 1000 + 57;
vector<int> kek[N];

void slv() {
	int n;
	cin >> n;

	vector<ll> v(n);
	cin >> v;

	ll sm = accumulate(all(v), 0LL);

	if (sm % n != 0) {
		cout << -1 << endl;
		return;
	}

	vector<pair<pair<int, int>, int>> ans;
	for (int i = 1; i < n; ++i) {
		int rem = (i + 1 - v[i] % (i + 1)) % (i + 1);

		ans.push_back({ {1, i + 1}, rem });
		v[0] -= rem;
		v[i] += rem;
		assert(v[0] >= 0);
		assert(v[i] % (i + 1) == 0);

		ans.push_back({ {i + 1, 1}, int(v[i]) / (i + 1) });
		v[0] += (v[i] / (i + 1)) * (i + 1);
		v[i] = 0;
	}

	int sr = sm / n;
	for (int i = 1; i < n; ++i) {
		ans.push_back({ { 1, i + 1 }, sr });
	}

	assert(sz(ans) <= 3 * n);
	cout << sz(ans) << endl;
	for (auto &pp : ans) {
		cout << pp << endl;
	}
}

inline void solve() {
	int t;
	cin >> t;

	while (t--) {
		slv();
	}
}

signed main() {

	if (*infile != '\0')
		assert(freopen(infile, "r", stdin));
	if (*outfile != '\0')
		assert(freopen(outfile, "w", stdout));

	speedup;
	coutdouble;

	//int tst = 1;
	//srand(time(NULL));
	//cin >> tst;
	//scanf("%d", &tst);
	//while (tst-- > 0) {
	//while (true)
	solve();
	//if ((tst & 0xF) == 0) {
	//cerr << "ok\n";
	//}
	//cerr << "/*-----------------*/\n";
	//}

#ifdef LOCAL
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << endl;
	while (true);
#endif // LOCAL

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
#include <functional>

#define N 13000
#define MOD 1000000007
using namespace std;
int n, m;
long long a[N];
struct ac {
	int i, j;
	long long x;
	ac(int i0, int j0, long long x0) {
		i = i0;
		j = j0;
		x = x0;
	}
};
vector<ac> ans;
int getMax(int x, int y) {
	return x > y ? x : y;
}
int getMin(int x, int y) {
	return x < y ? x : y;
}
int getAbs(int x) {
	return x > 0 ? x : -x;
}
void solve() {
	int i, j;
	long long sum = 0;
	scanf("%d", &n);
	ans.clear();
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		sum += (long long)a[i];
	}
	if (sum % n) {
		printf("-1\n");
		return;
	}
	sum /= n;
	for (i = 1; i < n; i++) {
		long long r = (long long)(i + 1 - (a[i] % (i + 1)));
		if (r > 0) {
			ac p1 = ac(1, i + 1, r);
			ans.push_back(p1);
			a[i] += r;
		}
		long long v = a[i] / (long long)(i + 1);
		if (v > 0) {
			ac p2 = ac(i + 1, 1, v);
			ans.push_back(p2);
		}
	}
	for (i = 1; i < n; i++) {
		ac p = ac(1, i + 1, sum);
		ans.push_back(p);
	}
	printf("%d\n", ans.size());
	for (ac p : ans) {
		printf("%d %d %lld\n", p.i, p.j, p.x);
	}

}

int main() {
	int tc;
	//freopen("c:\\data\\cin.txt", "r", stdin);
	scanf("%d", &tc);
	//while (scanf("%d", &n) != EOF) {
	//while (scanf("%s", &str) != EOF) {
	while (tc--){
		solve();
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
#include <functional>

#define N 13000
#define MOD 1000000007
using namespace std;
int n, m;
long long a[N];
struct ac {
	int i, j;
	long long x;
	ac(int i0, int j0, long long x0) {
		i = i0;
		j = j0;
		x = x0;
	}
};
vector<ac> ans;
int getMax(int x, int y) {
	return x > y ? x : y;
}
int getMin(int x, int y) {
	return x < y ? x : y;
}
int getAbs(int x) {
	return x > 0 ? x : -x;
}
void solve() {
	int i, j;
	long long sum = 0;
	scanf("%d", &n);
	ans.clear();
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		sum += (long long)a[i];
	}
	if (sum % n) {
		printf("-1\n");
		return;
	}
	sum /= n;
	for (i = 1; i < n; i++) {
		if (a[i] > sum) {
			long long v = (a[i] - sum + i) / (long long)(i + 1);
			ac p = ac(i + 1, 1, v);
			ans.push_back(p);
			a[i] -= (long long)(i + 1) * v;
		}
	}
	for (i = 1; i < n; i++) {
		if (a[i] < sum) {
			ac p = ac(1, i + 1, sum-a[i]);
			ans.push_back(p);
		}
	}
	printf("%d\n", ans.size());
	for (ac p : ans) {
		printf("%d %d %lld\n", p.i, p.j, p.x);
	}

}

int main() {
	int tc;
	//freopen("c:\\data\\cin.txt", "r", stdin);
	scanf("%d", &tc);
	//while (scanf("%d", &n) != EOF) {
	//while (scanf("%s", &str) != EOF) {
	while (tc--){
		solve();
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
#include <functional>

#define N 13000
#define MOD 1000000007
using namespace std;
int n, m;
long long a[N];
struct ac {
	int i, j;
	long long x;
	ac(int i0, int j0, long long x0) {
		i = i0;
		j = j0;
		x = x0;
	}
};
vector<ac> ans;
int getMax(int x, int y) {
	return x > y ? x : y;
}
int getMin(int x, int y) {
	return x < y ? x : y;
}
int getAbs(int x) {
	return x > 0 ? x : -x;
}
void solve() {
	int i, j;
	long long sum = 0;
	scanf("%d", &n);
	ans.clear();
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		sum += (long long)a[i];
	}
	sum /= n;
	for (i = 1; i < n; i++) {
		if (a[i] > sum) {
			long long v = (a[i] - sum + i) / (long long)(i + 1);
			ac p = ac(i + 1, 1, v);
			ans.push_back(p);
			a[i] -= (long long)(i + 1) * v;
		}
	}
	for (i = 1; i < n; i++) {
		if (a[i] < sum) {
			ac p = ac(1, i + 1, sum-a[i]);
			ans.push_back(p);
		}
	}
	printf("%d\n", ans.size());
	for (ac p : ans) {
		printf("%d %d %lld\n", p.i, p.j, p.x);
	}

}

int main() {
	int tc;
	//freopen("c:\\data\\cin.txt", "r", stdin);
	scanf("%d", &tc);
	//while (scanf("%d", &n) != EOF) {
	//while (scanf("%s", &str) != EOF) {
	while (tc--){
		solve();
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
#include <functional>

#define N 13000
#define MOD 1000000007
using namespace std;
int n, m;
long long a[N];
struct ac {
	int i, j;
	long long x;
	ac(int i0, int j0, long long x0) {
		i = i0;
		j = j0;
		x = x0;
	}
};
vector<ac> ans;
int getMax(int x, int y) {
	return x > y ? x : y;
}
int getMin(int x, int y) {
	return x < y ? x : y;
}
int getAbs(int x) {
	return x > 0 ? x : -x;
}
void solve() {
	int i, j;
	long long sum = 0;
	scanf("%d", &n);
	ans.clear();
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		sum += (long long)a[i];
	}
	if (sum % n) {
		printf("-1\n");
		return;
	}
	sum /= n;
	for (i = 1; i < n; i++) {
		long long r = (long long)(i + 1 - (a[i] % (i + 1)));
		r %= (long long)(i + 1);
		if (r > 0) {
			ac p1 = ac(1, i + 1, r);
			ans.push_back(p1);
			a[i] += r;
		}
		long long v = a[i] / (long long)(i + 1);
		if (v > 0) {
			ac p2 = ac(i + 1, 1, v);
			ans.push_back(p2);
		}
	}
	for (i = 1; i < n; i++) {
		ac p = ac(1, i + 1, sum);
		ans.push_back(p);
	}
	printf("%d\n", ans.size());
	for (ac p : ans) {
		printf("%d %d %lld\n", p.i, p.j, p.x);
	}

}

int main() {
	int tc;
	//freopen("c:\\data\\cin.txt", "r", stdin);
	scanf("%d", &tc);
	//while (scanf("%d", &n) != EOF) {
	//while (scanf("%s", &str) != EOF) {
	while (tc--){
		solve();
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
#include <functional>

#define N 13000
#define MOD 1000000007
using namespace std;
int n, m;
long long a[N];
struct ac {
	int i, j;
	long long x;
	ac(int i0, int j0, long long x0) {
		i = i0;
		j = j0;
		x = x0;
	}
};
vector<ac> ans;
int getMax(int x, int y) {
	return x > y ? x : y;
}
int getMin(int x, int y) {
	return x < y ? x : y;
}
int getAbs(int x) {
	return x > 0 ? x : -x;
}
void solve() {
	int i, j;
	long long sum = 0;
	scanf("%d", &n);
	ans.clear();
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		sum += (long long)a[i];
	}
	if (sum % n) {
		printf("-1\n");
		return;
	}
	sum /= n;
	for (i = 1; i < n; i++) {
		long long v = a[i] / (long long)(i + 1);
		if (v == 0) continue;
		ac p = ac(i + 1, 1, v);
		ans.push_back(p);
		a[i] -= (long long)(i + 1) * v;
	}
	for (i = 1; i < n; i++) {
		if (a[i] > sum) {
			a[i] -= sum;
			long long r = (long long)(i + 1 - (a[i] %(i+1)));
			ac p1 = ac(1, i + 1, r);
			ans.push_back(p1);
			a[i] += r;
			long long v = a[i] / (long long)(i + 1);
			ac p2 = ac(i + 1, 1, v);
			ans.push_back(p2);
		} else if (a[i] < sum) {
			ac p = ac(1, i + 1, sum-a[i]);
			ans.push_back(p);
		}
	}
	printf("%d\n", ans.size());
	for (ac p : ans) {
		printf("%d %d %lld\n", p.i, p.j, p.x);
	}

}

int main() {
	int tc;
	//freopen("c:\\data\\cin.txt", "r", stdin);
	scanf("%d", &tc);
	//while (scanf("%d", &n) != EOF) {
	//while (scanf("%s", &str) != EOF) {
	while (tc--){
		solve();
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
#include <functional>

#define N 13000
#define MOD 1000000007
using namespace std;
int n, m;
long long a[N];
struct ac {
	int i, j;
	long long x;
	ac(int i0, int j0, long long x0) {
		i = i0;
		j = j0;
		x = x0;
	}
};
vector<ac> ans;
int getMax(int x, int y) {
	return x > y ? x : y;
}
int getMin(int x, int y) {
	return x < y ? x : y;
}
int getAbs(int x) {
	return x > 0 ? x : -x;
}
void solve() {
	int i, j;
	long long sum = 0;
	scanf("%d", &n);
	ans.clear();
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		sum += (long long)a[i];
	}
	if (sum % n) {
		printf("-1\n");
		return;
	}
	sum /= n;
	for (i = 1; i < n; i++) {
		long long v = a[i] / (long long)(i + 1);
		if (v == 0) continue;
		ac p = ac(i + 1, 1, v);
		ans.push_back(p);
		a[i] -= (long long)(i + 1) * v;
	}
	for (i = 1; i < n; i++) {
		if (a[i] > sum) {
			long long r = (long long)(i + 1 - (a[i] %(i+1)));
			ac p1 = ac(1, i + 1, r);
			ans.push_back(p1);
			a[i] += r;
			long long v = a[i] / (long long)(i + 1);
			ac p2 = ac(i + 1, 1, v);
			ans.push_back(p2);
		} else if (a[i] < sum) {
			ac p = ac(1, i + 1, sum-a[i]);
			ans.push_back(p);
		}
	}
	printf("%d\n", ans.size());
	for (ac p : ans) {
		printf("%d %d %lld\n", p.i, p.j, p.x);
	}

}

int main() {
	int tc;
	//freopen("c:\\data\\cin.txt", "r", stdin);
	scanf("%d", &tc);
	//while (scanf("%d", &n) != EOF) {
	//while (scanf("%s", &str) != EOF) {
	while (tc--){
		solve();
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
#include <functional>

#define N 13000
#define MOD 1000000007
using namespace std;
int n, m;
long long a[N];
struct ac {
	int i, j;
	long long x;
	ac(int i0, int j0, long long x0) {
		i = i0;
		j = j0;
		x = x0;
	}
};
vector<ac> ans;
int getMax(int x, int y) {
	return x > y ? x : y;
}
int getMin(int x, int y) {
	return x < y ? x : y;
}
int getAbs(int x) {
	return x > 0 ? x : -x;
}
void solve() {
	int i, j;
	long long sum = 0;
	scanf("%d", &n);
	ans.clear();
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		sum += (long long)a[i];
	}
	if (sum % n) {
		printf("-1\n");
		return;
	}
	sum /= n;
	for (i = 1; i < n; i++) {
		long long v = a[i] / (long long)(i + 1);
		if (v == 0) continue;
		ac p = ac(i + 1, 1, v);
		ans.push_back(p);
		a[i] -= (long long)(i + 1) * v;
	}
	for (i = 1; i < n; i++) {
		if (a[i] > sum) {
			a[i] -= sum;
			long long r = (long long)(i + 1 - (a[i] %(i+1)));
			ac p1 = ac(1, i + 1, r);
			ans.push_back(p1);
			a[i] += r;
			long long v = a[i] / (long long)(i + 1);
			ac p2 = ac(i + 1, 1, v);
			ans.push_back(p2);
			a[i] = sum;
		}
	}
	for (i = 1; i < n; i++) {
		if (a[i] < sum) {
			ac p = ac(1, i + 1, sum - a[i]);
			ans.push_back(p);
		}
	}
	printf("%d\n", ans.size());
	for (ac p : ans) {
		printf("%d %d %lld\n", p.i, p.j, p.x);
	}

}

int main() {
	int tc;
	//freopen("c:\\data\\cin.txt", "r", stdin);
	scanf("%d", &tc);
	//while (scanf("%d", &n) != EOF) {
	//while (scanf("%s", &str) != EOF) {
	while (tc--){
		solve();
	}
	return 0;
}


#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include <iostream>
#include <iomanip>
#include <random>
#include <map>
#include <list>
#include<set>
#include <time.h>
using namespace std;

#define FOR(n) for(int i=0;i<n;++i)
#define FORj(n) for(int j=0;j<n;++j)
#define pb push_back
#define ll long long
#define vecI vector<int>
#define vecII vector<vector<int>>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ld long double
int a[10000];
int main()
{
	int n,t,s=0,x,y,z;
	cin >> t;
	while (t--)
	{
		s = 0;
		cin >> n;
		FOR(n)
		{
			cin >> a[i];
			s += a[i];
		}
		if (s%n)
		{
			cout << "-1 ";
			continue;
		}
		cout << 3 * n - 3 << ' ';
		for (int i = 1; i < n; ++i)
		{
			x = 1;
			y = i + 1;
			z = ((i + 1) - a[i] % (i + 1)) % (i + 1);
			cout << x << ' ' << y << ' ' << z << ' ';
			a[0] -= z;
			a[i] += z;
			cout << i + 1 << ' ' << 1 << ' ' << a[i] / (i + 1)<<' ';
			a[0] += a[i];
			a[i] = 0;
		}
		for (int i = 2; i <= n; ++i)
			cout << 1 << ' ' << i << ' ' << s / n<<' ';
	}
}


	#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256777216")
#include<iostream>
	#include<vector>
	#include<algorithm>
	#include<set>
	#include<unordered_set>
	#include<map>
	#include<unordered_map>
	#include<stack>
	#include<string>
	#include <queue>
	#include<cmath>
	#include <iomanip>
	#include<stdio.h>
	#include<bitset>
	using namespace std;
	const int MAXN = 4e5;
	const int MOD = 998244353;
	typedef long long ll;

	vector<int> ar1[MAXN];
	void solve()
	{
		int t;
		cin >> t;
		while (t--)
		{
			int n;
			cin >> n;
			ll sum = 0;
			vector<int> ar(n);
			for (int i = 0; i < n; ++i)
			{
				cin >> ar[i];
				sum += ar[i];
			}
			if (sum % n != 0)
			{
				cout << -1 << '\n';
				continue;
			}
			cout << 3 * (n - 1) << '\n';
			for (int i = 1; i < n; ++i)
			{
				int del = i + 1;
				int required_distance = ((del - ar[i] % del) % del);
				cout << 1 << ' ' << i + 1 << ' ' << required_distance << '\n';
				cout << i + 1 << ' ' << 1 << ' ' << (ar[i] + required_distance) / del << '\n';
			}
			for (int i = 1; i < n; ++i)
			{
				cout << 1 << ' ' << i + 1 << ' ' << sum / n << '\n';
			}
		}

	}
	int main()
	{
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);

			solve();
		return 0;
	}


	#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256777216")
#include<iostream>
	#include<vector>
	#include<algorithm>
	#include<set>
	#include<unordered_set>
	#include<map>
	#include<unordered_map>
	#include<stack>
	#include<string>
	#include <queue>
	#include<cmath>
	#include <iomanip>
	#include<stdio.h>
	#include<bitset>
	using namespace std;
	const int MAXN = 4e5;
	const int MOD = 998244353;
	typedef long long ll;

	vector<int> ar1[MAXN];
	void solve()
	{
		int t;
		cin >> t;
		while (t--)
		{
			int n;
			cin >> n;
			ll sum = 0;
			vector<int> ar(n);
			for (int i = 0; i < n; ++i)
			{
				cin >> ar[i];
				sum += ar[i];
			}
			if (sum % n != 0)
			{
				cout << -1 << '\n';
				continue;
			}
			cout << 3 * (n - 1) << '\n';
			for (int i = 1; i < n; ++i)
			{
				int del = i + 1;
				int required_distance = ((del - ar[i] % del) % del);
				cout << 1 << ' ' << i + 1 << ' ' << required_distance << '\n';
				cout << i + 1 << ' ' << 1 << ' ' << ar[i] + required_distance << '\n';
			}
			for (int i = 1; i < n; ++i)
			{
				cout << 1 << ' ' << i + 1 << ' ' << sum / n << '\n';
			}
		}

	}
	int main()
	{
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);

			solve();
		return 0;
	}


/*
DavitMarg
In a honky-tonk,
Down in Mexico
*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
#define fastIO ios::sync_with_stdio(false); cin.tie(0)
using namespace std;

const int N = 200005;

int n;
LL a[N],sum;
vector<pair<pair<int, int>, LL>> ans;

void solve()
{
    ans.clear();
    sum = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if (sum % n)
    {
        cout << "-1\n";
        return;
    }

    for (int i = 2; i <= n; i++)
    {
        if (a[i] % i)
        {
            ans.push_back(MP(MP(1,i), i - a[i] % i));
            a[i] += i - a[i] % i;
        }
        ans.push_back(MP(MP(i, 1), a[i] / i));
    }
    for (int i = 2; i <= n; i++)
        ans.push_back(MP(MP(1, i),sum/n));
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++)
        cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second << endl;
}

int main()
{
    fastIO;
    int T;
    cin >> T;
    while (T--)
        solve();

    return 0;
}

/*

*/


#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int N = 3e5 + 10;

ll n, m;
ll s[N];
char str[N];

struct node{
	ll a, b, c;
}f[N];

int main()
{
    int t;
	cin >> t;
	while (t--)
	{
		ll sum = 0, avg = 0, k = 0, cnt = 0;
		scanf("%lld", &n);
		for (int i = 1; i <= n; i++)
		{
			scanf("%lld", &s[i]);
			sum += s[i];
		}
		if (sum % n != 0)
		{
			printf("-1\n");
			continue;
	    }
		avg = sum / n;
		for (int i = 2; i <= n; i++)
		{
			if (s[i] > avg)
			{
			    if ((s[i] - avg) % i == 0)
		    	{
		    		f[cnt].a = i;
		    		f[cnt].b = 1;
		    		f[cnt++].c = (s[i] - avg) / i;
		    	    s[1] += s[i] - avg;
		    	    s[i] = avg;
		    	    k++;
		    	}
		    	else if (s[i] > ((s[i] - avg) / i + 1) * i)
		    	{
		    		f[cnt].a = i;
		    		f[cnt].b = 1;
		    		f[cnt++].c = (s[i] - avg) / i + 1;
		    		s[1] += ((s[i] - avg) / i + 1) * i;
		    	    s[i] -= ((s[i] - avg) / i + 1) * i;
		        	k++;
		    	}

				else
		    	{
		    		f[cnt].a = i;
		    		f[cnt].b = 1;
		    		f[cnt++].c = (s[i] - avg) / i;
		    		s[1] += (s[i] - avg) / i * i;
		    	    s[i] -= (s[i] - avg) / i * i;
		        	k++;
		    	}
		    }
		}
		for (int i = n; i >= 2; i--)
		{
			if (s[i] > avg)
			{
				f[cnt].a = 1;
				f[cnt].b = i;
				f[cnt++].c = i + avg - s[i];
				f[cnt].a = i;
				f[cnt].b = 1;
				f[cnt++].c = 1;
				k += 2;
				s[1] += s[i] - avg;
				s[i] = avg;
			}
		}
		for (int i = 2; i <= n; i++)
		{
			if (s[i] < avg)
			{
				f[cnt].a = 1;
				f[cnt].b = i;
				f[cnt++].c = avg - s[i];
				k++;
				s[1] -= avg - s[i];
				s[i] = avg;
			}
		}
		printf("%lld\n", k);
		for (int i = 0; i < cnt; i++)
		{
			printf("%lld %lld %lld\n", f[i].a, f[i].b, f[i].c);
			f[i].a = 0;
			f[i].b = 0;
			f[i].c = 0;
		}
	}
    return 0;
}


#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int N = 3e5 + 10;

ll n, m;
ll s[N];
char str[N];

struct node{
	ll a, b, c;
}f[N];

int main()
{
    int t;
	cin >> t;
	while (t--)
	{
		ll sum = 0, avg = 0, k = 0, cnt = 0;
		scanf("%lld", &n);
		for (int i = 1; i <= n; i++)
		{
			scanf("%lld", &s[i]);
			sum += s[i];
		}
		if (sum % n != 0)
		{
			printf("-1\n");
			continue;
	    }
		avg = sum / n;
		for (int i = 2; i <= n; i++)
		{
			if (s[i] > i)
			{
			    if (s[i] % i == 0)
		    	{
		    		f[cnt].a = i;
		    		f[cnt].b = 1;
		    		f[cnt++].c = s[i] / i - 1;
		    	    s[1] += s[i] - i;
		    	    s[i] = i;
		    	    k++;
		    	}
				else
		    	{
		    		f[cnt].a = i;
		    		f[cnt].b = 1;
		    		f[cnt++].c = s[i] / i;
		    		s[1] += s[i] / i * i;
		    	    s[i] = s[i] % i;
		        	k++;
		    	}
		    }
		}
		for (int i = n; i >= 2; i--)
		{
			if (s[i] > avg)
			{
				f[cnt].a = 1;
				f[cnt].b = i;
				f[cnt++].c = i + avg - s[i];
				f[cnt].a = i;
				f[cnt].b = 1;
				f[cnt++].c = 1;
				k += 2;
				s[1] += s[i] - avg;
				s[i] = avg;
			}
		}
		for (int i = 2; i <= n; i++)
		{
			if (s[i] < avg)
			{
				f[cnt].a = 1;
				f[cnt].b = i;
				f[cnt++].c = avg - s[i];
				k++;
				s[1] -= avg - s[i];
				s[i] = avg;
			}
		}
		printf("%lld\n", k);
		for (int i = 0; i < cnt; i++)
		{
			printf("%lld %lld %lld\n", f[i].a, f[i].b, f[i].c);
			f[i].a = 0;
			f[i].b = 0;
			f[i].c = 0;
		}
	}
    return 0;
}


#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int N = 3e5 + 10;

ll n, m;
ll s[N];
char str[N];

struct node{
	ll a, b, c;
}f[N];

int main()
{
    int t;
	cin >> t;
	while (t--)
	{
		ll sum = 0, avg = 0, k = 0, cnt = 0;
		scanf("%lld", &n);
		for (int i = 1; i <= n; i++)
		{
			scanf("%lld", &s[i]);
			sum += s[i];
		}
		if (sum % n != 0)
		{
			printf("-1\n");
			continue;
	    }
		avg = sum / n;
		for (int i = 2; i <= n; i++)
		{
			if (s[i] > avg)
			{
			    if ((s[i] - avg) % i == 0)
		    	{
		    		f[cnt].a = i;
		    		f[cnt].b = 1;
		    		f[cnt++].c = (s[i] - avg) / i;
		    	    s[1] += s[i] - avg;
		    	    s[i] = avg;
		    	    k++;
		    	}
		    	else
		    	{
		    		f[cnt].a = i;
		    		f[cnt].b = 1;
		    		f[cnt++].c = (s[i] - avg) / i;
		    		s[1] += (s[i] - avg) / i * i;
		    	    s[i] -= (s[i] - avg) / i * i;
		        	k++;
		    	}
		    }
		}
		for (int i = n; i >= 2; i--)
		{
			if (s[i] > avg)
			{
				f[cnt].a = 1;
				f[cnt].b = i;
				f[cnt++].c = i + avg - s[i];
				f[cnt].a = i;
				f[cnt].b = 1;
				f[cnt++].c = 1;
				k += 2;
				s[1] += s[i] - avg;
				s[i] = avg;
			}
		}
		for (int i = 2; i <= n; i++)
		{
			if (s[i] < avg)
			{
				f[cnt].a = 1;
				f[cnt].b = i;
				f[cnt++].c = avg - s[i];
				k++;
				s[1] -= avg - s[i];
				s[i] = avg;
			}
		}
		printf("%lld\n", k);
		for (int i = 0; i < cnt; i++)
		{
			printf("%lld %lld %lld\n", f[i].a, f[i].b, f[i].c);
			f[i].a = 0;
			f[i].b = 0;
			f[i].c = 0;
		}
	}
    return 0;
}


#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int N = 3e5 + 10;

ll n, m;
ll s[N];
ll ff;
char str[N];

struct node{
	ll a, b, c;
}f[N];

int main()
{
    int t;
	cin >> t;
	while (t--)
	{
		ll sum = 0, avg = 0, k = 0, cnt = 0;
		scanf("%lld", &n);
		for (int i = 1; i <= n; i++)
		{
			scanf("%lld", &s[i]);
			sum += s[i];
		}
		if (sum % n != 0)
		{
			printf("-1\n");
			continue;
	    }
		avg = sum / n;
		for (int i = 2; i <= n; i++)
		{
			if (s[i] > avg)
			{
			    if ((s[i] - avg) % i == 0)
		    	{
		    		f[cnt].a = i;
		    		f[cnt].b = 1;
		    		f[cnt++].c = (s[i] - avg) / i;
		    	    s[1] += s[i] - avg;
		    	    s[i] = avg;
		    	    k++;
		    	}
		    	else if (s[i] > ((s[i] - avg) / i + 1) * i)
		    	{
		    		f[cnt].a = i;
		    		f[cnt].b = 1;
		    		f[cnt++].c = (s[i] - avg) / i + 1;
		    		s[1] += ((s[i] - avg) / i + 1) * i;
		    	    s[i] -= ((s[i] - avg) / i + 1) * i;
		        	k++;
		    	}
		    }
		}
		for (int i = n; i >= 2; i--)
		{
			if (s[i] > avg)
			{
				f[cnt].a = 1;
				f[cnt].b = i;
				f[cnt++].c = i + avg - s[i];
				f[cnt].a = i;
				f[cnt].b = 1;
				f[cnt++].c = 1;
				k += 2;
				s[1] += s[i] - avg;
				s[i] = avg;
			}
		}
		for (int i = 2; i <= n; i++)
		{
			if (s[i] < avg)
			{
				f[cnt].a = 1;
				f[cnt].b = i;
				f[cnt++].c = avg - s[i];
				k++;
				s[1] -= avg - s[i];
				s[i] = avg;
			}
		}
		printf("%lld\n", k);
		for (int i = 0; i < cnt; i++)
		{
			printf("%lld %lld %lld\n", f[i].a, f[i].b, f[i].c);
		}
	}
    return 0;
}


#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int N = 3e5 + 10;
const int maxn = 4e4 + 5;

ll n, m;
ll s[N];
char str[N];

struct node{
	ll a, b, c;
}f[N];

int Start[maxn], l[maxn], ans[maxn], ANS[maxn], lu[5][maxn],CNT;
ll a[maxn];

struct E
{
	int id,spare;
};
bool operator <(E x,E y)
{
	if(x.spare == y.spare){
		return x.id < y.id;
	}
	else return x.spare > y.spare;
}
priority_queue<E> P;

void insert(int x1, int x2, int v1)
{
	++CNT;
	lu[1][CNT] = x1;
	lu[2][CNT] = x2;
	lu[3][CNT] = v1;
}
int main()
{
	int T, n;
	cin >> T;
	while(T--)
	{
		cin >> n;
		CNT = 0;
		ll tot = 0;
		for(int i = 1; i <= n; i++){
			cin >> a[i];
			tot += a[i];
		}
		if(tot % n != 0){
			cout << "-1" << endl;
			continue;
		}
		tot = tot / n;
		for(int i = 2; i <= n; i++){
			int m = a[i] / i;
			ll Q = 1ll * m * i;
			if(Q != 0){
				if(a[i] - Q == 0){
					a[i] -= Q;
					a[1] += Q;
					insert(i,1,m);
				}
				else{
					if(a[1] >= i - (a[i] - Q)){
						insert(1, i, i - (a[i] - Q));
						insert(i, 1, m + 1);
						a[1] += a[i];
						a[i] = 0;
					}
					else{
						a[i] -= Q;
						a[1] += Q;
						insert(i, 1, m);
					}
				}
			}
			if(a[i] > 0){
				E CN;
				CN.id = i;
				CN.spare = i - a[i];
				P.push(CN);
			}
		}
		int flag = 1;
		while(!P.empty())
		{
			E CN = P.top();
			P.pop();
			ll X_1 = CN.id;
			ll res = X_1-a[X_1];
			if(a[1] < res){
				flag = 0;
				break;
			}
			a[1] -= res;
			a[X_1] += res;
			insert(1, X_1, res);
			a[1] += X_1;
			a[X_1] -= X_1;
			insert(X_1, 1, 1);
		}
		if(flag == 0){
			cout << "-1" << endl;
			continue;
		}
		for(int i = 2; i <= n; i++){
			int X_1 = tot - a[i];
			a[1] -= X_1;
			a[i] += X_1;
			insert(1, i, X_1);
		}
		if(CNT > 3 * n){
			cout << "-1" << endl;
			continue;
		}
		else{
			cout << CNT << endl;
			for(int i = 1; i <= CNT; i++){
				cout << lu[1][i] << ' ' << lu[2][i] << ' ' << lu[3][i] << endl;
			}
		}
	}
}


for _ in range(int(input())):
    n=int(input());c=0;a=[]
    l=list(map(int,input().split()));x=sum(l)
    if x%n!=0:print(-1);continue
    for i in range(1,n):
        j=i+1
        if l[i]%j==0:a.append([j,1,l[i]//j]);c+=1
        else:a.append([j,1,(a-a%j)//j]);a.append([j,1,(a-a%j)//j]);c+=2
    for i in range(1,n):a.append([1,i+1,x//n]);c+=1
    print(c)
    for i in a:print(*i)


for s in[*open(0)][2::2]:
    l=list(map(int,s.split()));x=sum(l);n=len(l);c=0;a=[]
    if x%n!=0:print(-1);continue
    for i in range(1,n):
        j=i+1
        if l[i]%j==0:a.append([j,1,l[i]//j]);c+=1
        else:a.append([j,1,(a-a%j)//j]);a.append([j,1,(a-a%j)//j]);c+=2
    for i in range(1,n):a.append([1,i+1,x//n]);c+=1
    print(c)
    for i in a:print(*i)


for s in[*open(0)][2::2]:
    l=list(map(int,s.split()));x=sum(l);n=len(l)
    if x%n!=0:print(-1);continue
    for i in range(1,n):
        j=i+1
        if l[i]%j==0:print(j,1,l[i]//j)
        else:print(1,j,l[i]+j-l[i]%j);print(j,1,(l[i]+j-l[i]%j)//j)
    for i in range(1,n):print(1,i+1,x//n)


for s in[*open(0)][2::2]:
    l=list(map(int,s.split()));x=sum(l);n=len(l)
    if x%n!=0:print(-1);continue
    for i in range(1,n):
        if l[i]%(i+1)==0:print(i+1,1,l[i]//i)
        else:print(1,1+i,l[i]+i-l[i]);print(i+1,1,(l[i]+i-l[i]%i)//i)
    for i in range(1,n):print(1,i+1,x//n)


for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    a=[];x=sum(l);x+=[3*n-3]
    if x%n!=0:print(-1);continue
    for i in range(2,n+1):p=i-l[i-1]%i;a+=[1,i,p];a+=[i,1,(l[i]+p)//i]
    for i in range(1,n):a+=[1,i+1,x//n]
    for i in a:print(*i)


for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    a=[];x=sum(l);c=0
    if x%n!=0:print(-1);continue
    for i in range(1,n):
        j=i+1
        if l[i]%j==0:a.append([j,1,l[i]//j]);c+=1
        else:a.append([j,1,(a-a%j)//j]);a.append([j,1,(a-a%j)//j]);c+=2
    for i in range(1,n):a.append([1,i+1,x//n]);c+=1
    print(c)
    for i in a:print(*i)


for s in[*open(0)][2::2]:
    l=list(map(int,s.split()));x=sum(l);n=len(l);c=0;a=[]
    if x%n!=0:print(-1);continue
    for i in range(1,n):
        j=i+1
        if l[i]%j==0:a.append([j,1,l[i]//j]);c+=1
        else:a.append([1,j,l[i]+j-l[i]%j]);a.append([j,1,(l[i]+j-l[i]%j)//j]);c+=2
    for i in range(1,n):a.append([1,i+1,x//n]);c+=1
    print(c)
    for i in a:print(*i)


for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    s = sum(a)
    if s%n!=0:print(-1);continue
    t = s//n
    print(3*(n-1))
    for i in range(1, n):
        x = (i+1)-a[i]%(i+1)
        if a[i]%(i+1) == 0:
            x = 0
        a[i]+=x
        print(1, i+1, x)
        print(i+1, 1, a[i]//(i+1))
    for i in range(1, n):print(1, i+1, t)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	a = list(mints())
	s = sum(a)
	if s % n != 0:
		print(-1)
		return
	s //= n
	res = []
	for i in range(1,n):
		if a[i] >= i+1:
			x = a[i]//(i+1)
			res.append((i+1,1,x))
			a[i] -= x*(i+1)
			a[0] += x*(i+1)
			#print(a)
	for i in range(n-1,0,-1):
		if a[i] < s:
			x = s-a[i]
			if x > a[0]-s:
				print(-1)
				return
			res.append((1, i+1, x))
			a[0] -= x
			a[i] += x
		elif a[i] > s:
			x = s+(i+1)-a[i]
			print(x)
			if x > a[0]:
				print(-1)
				return
			a[0] -= x-(i+1)
			a[i] += x-(i+1)
			res.append((1, i+1, x))
			res.append((i+1, 1, 1))
		if a[i] != s:
			print(-1)
			return
	if a[0] != s:
		print(-1)
		return
	print(len(res))
	for a in res:
		print(*a)
	'''
	i = 1
	res = []
	for j in range(n-1,-1,-1):
		while a[j] != s:
			if a[j] > s:
				x = ((a[j]-s)+j)//(j+1)
				res.append((j+1, 1, x))
				a[j] -= x*(j+1)
				a[0] += x*(j+1)
				#print(a)
			elif a[j] < s:
				if a[0]-s >= s-a[j]:
					x = s-a[j]
					res.append((1, j+1, x))
					a[0] -= x
					a[j] += x
					#print(a)
				elif i < n:
					if a[i] >= i+1:
						x = (a[i]-1)//(i+1)
						a[i] -= x*(i+1)
						a[0] += x*(i+1)
						res.append((i+1, 1, x))
						#print(a)
					i += 1
				else:
					print(-1)
					return
	print(len(res))
	for a in res:
		print(*a)
	#print('--------')'''

for i in range(mint()):
	solve()


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	a = list(mints())
	s = sum(a)
	if s % n != 0:
		print(-1)
		return
	s //= n
	i = 1
	res = []
	for j in range(n-1,-1,-1):
		while a[j] != s:
			if a[j] > s:
				x = ((a[j]-s)+j)//(j+1)
				res.append((j+1, 1, x))
				a[j] -= x*(j+1)
				a[0] += x*(j+1)
				#print(a)
			elif a[j] < s:
				if a[0]-s >= s-a[j]:
					x = s-a[j]
					res.append((1, j+1, x))
					a[0] -= x
					a[j] += x
					#print(a)
				elif i < n:
					if a[i] >= i+1:
						x = (a[i]-1)//(i+1)
						a[i] -= x*(i+1)
						a[0] += x*(i+1)
						res.append((i+1, 1, x))
						#print(a)
					i += 1
				else:
					print(-1)
					return
	print(len(res))
	for a in res:
		print(*a)
	#print('--------')

for i in range(mint()):
	solve()


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	a = list(mints())
	s = sum(a)
	if s % n != 0:
		print(-1)
		return
	s //= n
	res = []
	for i in range(1,n):
		if a[i] >= i+1:
			x = a[i]//(i+1)
			res.append((i+1,1,x))
			a[i] -= x*(i+1)
			a[0] += x*(i+1)
			#print(a)
	for i in range(n-1,0,-1):
		if a[i] < s:
			x = s-a[i]
			if x > a[0]-s:
				print(-1)
				return
			res.append((1, i+1, x))
			a[0] -= x
			a[i] += x
		elif a[i] > s:
			x = s+(i+1)-a[i]
			if x > a[0]:
				print(-1)
				return
			a[0] -= x-(i+1)
			a[i] += x-(i+1)
			res.append((1, i+1, x))
			res.append((i+1, 1, 1))
		if a[i] != s:
			print(-1)
			return
	if a[0] != s:
		print(-1)
		return
	print(len(res))
	for a in res:
		print(*a)
	'''
	i = 1
	res = []
	for j in range(n-1,-1,-1):
		while a[j] != s:
			if a[j] > s:
				x = ((a[j]-s)+j)//(j+1)
				res.append((j+1, 1, x))
				a[j] -= x*(j+1)
				a[0] += x*(j+1)
				#print(a)
			elif a[j] < s:
				if a[0]-s >= s-a[j]:
					x = s-a[j]
					res.append((1, j+1, x))
					a[0] -= x
					a[j] += x
					#print(a)
				elif i < n:
					if a[i] >= i+1:
						x = (a[i]-1)//(i+1)
						a[i] -= x*(i+1)
						a[0] += x*(i+1)
						res.append((i+1, 1, x))
						#print(a)
					i += 1
				else:
					print(-1)
					return
	print(len(res))
	for a in res:
		print(*a)
	#print('--------')'''

for i in range(mint()):
	solve()


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	a = list(mints())
	s = sum(a)
	if s % n != 0:
		print(-1)
		return
	s //= n
	res = []
	for i in range(1,n):
		if a[i] >= i+1:
			x = a[i]//(i+1)
			res.append((i+1,1,x))
			a[i] -= x*(i+1)
			a[0] += x*(i+1)
	for i in range(1,n):
		if a[i] < s:
			if s-a[i] > a[0]-s:
				print(-1)
				return
			x = s-a[i]
			res.append((1, i+1, x))
			a[0] -= x
			a[i] += x
		if a[i] != s:
			print(-1)
			return
	if a[0] != s:
		print(-1)
		return
	print(len(res))
	for a in res:
		print(*a)
	'''
	i = 1
	res = []
	for j in range(n-1,-1,-1):
		while a[j] != s:
			if a[j] > s:
				x = ((a[j]-s)+j)//(j+1)
				res.append((j+1, 1, x))
				a[j] -= x*(j+1)
				a[0] += x*(j+1)
				#print(a)
			elif a[j] < s:
				if a[0]-s >= s-a[j]:
					x = s-a[j]
					res.append((1, j+1, x))
					a[0] -= x
					a[j] += x
					#print(a)
				elif i < n:
					if a[i] >= i+1:
						x = (a[i]-1)//(i+1)
						a[i] -= x*(i+1)
						a[0] += x*(i+1)
						res.append((i+1, 1, x))
						#print(a)
					i += 1
				else:
					print(-1)
					return
	print(len(res))
	for a in res:
		print(*a)
	#print('--------')'''

for i in range(mint()):
	solve()


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	a = list(mints())
	s = sum(a)
	if s % n != 0:
		print(-1)
		return
	s //= n
	res = []
	for i in range(1,n):
		x = a[i]%(i+1)
		if x != 0:
			res.append((1,i+1,i+1-x))
			a[i] += i+1-x
			a[0] -= i+1-x
		if a[i] % (i+1) != 0:
			raise Exception('wut')
		x = a[i] // (i+1)
		res.append((i+1,1,x))
		a[i] = 0
		a[0] += x * (i+1)
	for i in range(1,n):
		if a[i] < s:
			x = s-a[i]
			if x > a[0]-s:
				print(-1)
				return
			res.append((1, i+1, x))
			a[0] -= x
			a[i] += x
		if a[i] != s:
			raise Exception('wut')
	if a[0] != s:
		raise Exception('wut')
		return
	print(len(res))
	for a in res:
		print(*a)
	'''
	i = 1
	res = []
	for j in range(n-1,-1,-1):
		while a[j] != s:
			if a[j] > s:
				x = ((a[j]-s)+j)//(j+1)
				res.append((j+1, 1, x))
				a[j] -= x*(j+1)
				a[0] += x*(j+1)
				#print(a)
			elif a[j] < s:
				if a[0]-s >= s-a[j]:
					x = s-a[j]
					res.append((1, j+1, x))
					a[0] -= x
					a[j] += x
					#print(a)
				elif i < n:
					if a[i] >= i+1:
						x = (a[i]-1)//(i+1)
						a[i] -= x*(i+1)
						a[0] += x*(i+1)
						res.append((i+1, 1, x))
						#print(a)
					i += 1
				else:
					print(-1)
					return
	print(len(res))
	for a in res:
		print(*a)
	#print('--------')'''

for i in range(mint()):
	solve()


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

    s = sum(y)
    if s % n == 0:
        res = list()
        for k in range(1, n):
            if y[k] % (k + 1) != 0:
                r = y[k] % (k + 1)
                x = (k + 1) - r
                y[k] += x
                y[0] -= x
                res.append([1, k + 1, x])
            x = int(y[k] / (k + 1))
            y[k] -= x * (k + 1)
            y[0] += x * (k + 1)
            res.append([k + 1, 1, x])

        avg = int(s / n)
        for k in range(1, n):
            y[0] -= avg
            y[k] += avg
            res.append([1, k + 1, avg])

        print(len(res))
        for i in res:
            print(i[0], i[1], i[2])
    else:
        print(-1)


from sys import stdin
def solve():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split())
    s = sum(a)
    if s % n:
        print -1
        return
    s /= n
    ans = []
    for i, x in enumerate(a, 1):
        if i > 1:
            p = i - x % i
            a[i-1] += p
            a[0] -= p
            ans.append((1, i, p))
            a[0] += a[i-1]
            ans.append((i, 1, a[i-1] / i))
    for i, x in enumerate(a, 1):
        ans.append((1, i, s))
    print len(ans)
    for x, y, z in ans:
        print x, y, z
T = int(stdin.readline())
for t in xrange(T):
    solve()


from sys import stdin
def solve():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split())
    s = sum(a)
    if s % n:
        print -1
        return
    s /= n
    ans = []
    for i, x in enumerate(a, 1):
        if i > 1:
            p = x / i
            if p:
                ans.append((i, 1, p))
                a[i-1] -= i * p
                a[0] += i * p
                break
    q = []
    for i, x in enumerate(a, 1):
        if i > 1 and x:
            q.append((i - x, i))
    q.sort()
    for p, i in q:
        ans.append((1, i, p))
        a[i-1] += p
        a[0] -= p
        if a[0] < 0:
            print -1
            return
        a[i-1] -= i
        a[0] += i
        ans.append((i, 1, 1))
    for i, x in enumerate(a, 1):
        ans.append((1, i, s))
    print len(ans)
    for x, y, z in ans:
        print x, y, z
T = int(stdin.readline())
for t in xrange(T):
    solve()


from sys import stdin
def solve():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split())
    s = sum(a)
    if s % n:
        print -1
        return
    s /= n
    ans = []
    for i, x in enumerate(a, 1):
        if i > 1:
            p = x / i
            if p:
                ans.append((i, 1, p))
                a[i-1] -= i * p
                a[0] += i * p
                break
    q = []
    for i, x in enumerate(a, 1):
        if i > 1 and x % i:
            q.append((i - x % i, i))
    q.sort()
    for p, i in q:
        ans.append((1, i, p))
        a[i-1] += p
        a[0] -= p
        if a[0] < 0:
            print -1
            return
        a[i-1] -= i
        a[0] += i
        ans.append((i, 1, 1))
    for i, x in enumerate(a, 1):
        ans.append((1, i, s))
    print len(ans)
    for x, y, z in ans:
        print x, y, z
T = int(stdin.readline())
for t in xrange(T):
    solve()


from sys import stdin
def solve():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split())
    s = sum(a)
    if s % n:
        print -1
        return
    s /= n
    ans = []
    for i, x in enumerate(a, 1):
        if i > 1:
            if x % i:
                p = i - x % i
                a[i-1] += p
                a[0] -= p
                ans.append((1, i, p))
            a[0] += a[i-1]
            ans.append((i, 1, a[i-1] / i))
    for i, x in enumerate(a, 1):
        ans.append((1, i, s))
    print len(ans)
    for x, y, z in ans:
        print x, y, z
T = int(stdin.readline())
for t in xrange(T):
    solve()


from sys import stdin
def solve():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split())
    s = sum(a)
    if s % n:
        print -1
        return
    s /= n
    ans = []
    for i, x in enumerate(a, 1):
        if i > 1 and x > s:
            p = (x - s + i - 1) / i
            ans.append((i, 1, p))
            a[i-1] -= i * p
            a[0] += i * p
    for i, x in enumerate(a, 1):
        if x < s:
            ans.append((1, i, s - x))
    print len(ans)
    for x, y, z in ans:
        print x, y, z
T = int(stdin.readline())
for t in xrange(T):
    solve()