#include <bits/stdc++.h>   using namespace std;   long long int max(long long int a, long long int b) {     if (a > b)       return a;     else       return b;   }   long long int min(long long int a, long long int b) {     if (a < b)       return a;     else       return b;   }   const int dx[4] = {-1, 1, 0, 0};   const int dy[4] = {0, 0, -1, 1};   int XX[] = {-1, -1, -1, 0, 0, 1, 1, 1};   int YY[] = {-1, 0, 1, -1, 1, -1, 0, 1};   vector<pair<long long int, pair<long long int, long long int> > > vec;   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     long long int t, n, i, j, k, l, r, m, q, g, b, u, v, x, y, z, num;     cin >> t;     while (t--) {       vec.clear();       cin >> n;       long long int arr[n + 1];       long long int sum = 0;       for (i = 1; i <= n; i++) {         cin >> arr[i];         sum += arr[i];       }       if (sum % n != 0) {         cout <<  -1               <<   n ;         continue;       }       for (i = 2; i < n; i++) {         long long int need = i - arr[i];         if (arr[i] <= i && need <= arr[1]) {           arr[1] -= need;           vec.push_back(make_pair(1, make_pair(i, need)));           vec.push_back(make_pair(i, make_pair(1, 1)));           arr[1] += i;           arr[i] = 0;         }       }       for (i = 2; i < n; i++) {         long long int need = i - arr[i];         if (arr[i] != 0 && arr[i] <= i && need <= arr[1]) {           arr[1] -= need;           vec.push_back(make_pair(1, make_pair(i, need)));           vec.push_back(make_pair(i, make_pair(1, 1)));           arr[1] += i;           arr[i] = 0;         }       }       long long int val = sum / n;       for (i = 2; i <= n; i++) {         if (arr[i] > i) {           x = arr[i] / i;           vec.push_back(make_pair(i, make_pair(1, x)));           arr[i] -= x * i;           arr[1] += x * i;         }       }       for (i = 2; i <= n; i++) {         if (arr[i] > val) {           long long int need = i + val - arr[i];           long long int profit = i;           if (need <= arr[1] && profit >= need) {             vec.push_back(make_pair(1, make_pair(i, need)));             arr[1] -= need;             arr[i] += need;             arr[i] -= i;             arr[1] += i;             vec.push_back(make_pair(i, make_pair(1, 1)));           }         }       }       long long int flag = 0;       for (i = 2; i <= n; i++) {         if (arr[i] > val) {           long long int need = i + val - arr[i];           long long int profit = i;           if (need <= arr[1]) {             vec.push_back(make_pair(1, make_pair(i, need)));             arr[1] -= need;             arr[i] += need;             arr[i] -= i;             arr[1] += i;             vec.push_back(make_pair(i, make_pair(1, 1)));           } else {             cout <<  -1                   <<   n ;             flag = 1;             break;           }         }       }       if (flag == 1) continue;       for (i = 2; i <= n; i++) {         if (arr[i] < val) {           long long int need = val - arr[i];           if (need > arr[1]) {             flag = 1;             cout <<  -1                   <<   n ;             break;           }           vec.push_back(make_pair(1, make_pair(i, need)));           arr[1] -= need;           arr[i] += need;         }       }       if (flag == 0) {         cout << vec.size() <<   n ;         for (i = 0; i < vec.size(); i++) {           cout << vec[i].first <<     << vec[i].second.first <<                    << vec[i].second.second <<   n ;         }       }     }   }