#include <bits/stdc++.h>
using namespace std;
struct op {
  long long i;
  long long j;
  long long x;
};
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    if (sum % n) {
      cout << -1 << "\n";
      continue;
    }
    vector<op> v;
    for (long long i = 1; i < n; i++) {
      struct op tuple;
      if (a[i] % (i + 1)) {
        tuple.i = 1;
        tuple.j = i + 1;
        tuple.x = (i + 1) - (a[i] % (i + 1));
        v.push_back(tuple);
        struct op tuple2;
        tuple2.i = i + 1;
        tuple2.j = 1;
        tuple2.x = (a[i] + (i + 1) - (a[i] % (i + 1))) / (i + 1);
        v.push_back(tuple2);
      } else {
        tuple.i = i + 1;
        tuple.j = 1;
        tuple.x = a[i] / (i + 1);
        v.push_back(tuple);
      }
    }
    for (long long i = 1; i < n; i++) {
      struct op tuple;
      tuple.i = 1;
      tuple.j = i + 1;
      tuple.x = sum / n;
      v.push_back(tuple);
    }
    cout << v.size() << "\n";
    for (long long i = 0; i < (long long)v.size(); i++) {
      cout << v[i].i << " " << v[i].j << " " << v[i].x << "\n";
    }
  }
}
