#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 7;
const long long mod = 1e9 + 7;
long long n, k;
long long a[N];
struct node {
  long long i, j, w;
  node(long long a, long long b, long long c) {
    i = a;
    j = b;
    w = c;
  }
};
vector<node> vt;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    vt.clear();
    cin >> n;
    long long sum = 0;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    if (sum % n != 0) {
      cout << -1 << endl;
      continue;
    }
    long long ave = sum / n;
    for (long long i = 2; i <= n; i++) {
      if (a[i] % i) {
        vt.push_back(node(1, i, i - a[i] % i));
      }
      vt.push_back(node(i, 1, (a[i] + i - 1) / i));
    }
    for (long long i = 2; i <= n; i++) {
      vt.push_back(node(1, i, ave));
    }
    cout << vt.size() << endl;
    for (long long i = 0; i < vt.size(); i++) {
      cout << vt[i].i << " " << vt[i].j << " " << vt[i].w << endl;
    }
  }
  return 0;
}
