#include <bits/stdc++.h>
using namespace std;
int t;
int main() {
  cin >> t;
  for (int q = 0; q < t; q++) {
    int n;
    cin >> n;
    int v[10001];
    int total = 0;
    vector<int> iSol, jSol, xSol;
    for (int i = 1; i <= n; i++) {
      cin >> v[i];
      total += v[i];
    }
    if (total % n == 0) {
      for (int i = 2; i <= n; i++) {
        int delta = v[i] % i;
        if (delta != 0) {
          v[1] -= (i - delta);
          v[i] += (i - delta);
          iSol.push_back(1);
          jSol.push_back(i);
          xSol.push_back(i - delta);
        }
        int mult = v[i] / i;
        v[1] += v[i];
        v[i] = 0;
        iSol.push_back(i);
        jSol.push_back(1);
        xSol.push_back(mult);
      }
      for (int i = 2; i <= n; i++) {
        v[i] += total / n;
      }
      v[1] = total / n;
      for (int i = 2; i <= n; i++) {
        iSol.push_back(1);
        jSol.push_back(i);
        xSol.push_back(total / n);
      }
      cout << iSol.size() << '\n';
      for (int i = 0; i < iSol.size(); i++) {
        cout << iSol[i] << " " << jSol[i] << " " << xSol[i] << '\n';
      }
    } else {
      cout << -1 << '\n';
    }
  }
  return 0;
}
