#include <bits/stdc++.h>
using namespace std;
int n;
int ar[555555];
void doit() {
  scanf("%i", &n);
  for (int i = 0; i < (n); i++) scanf("%i", ar + i);
  int tot = 0;
  for (int i = 0; i < (n); i++) tot += ar[i];
  if (tot % n) {
    printf("-1\n");
    return;
  }
  vector<int> from, to, x;
  for (int i = 1; i < n; i++) {
    if (ar[i] % (i + 1)) {
      from.push_back(0);
      to.push_back(i);
      int targ = ar[i] / (i + 1);
      targ++;
      targ *= i + 1;
      x.push_back(targ - ar[i]);
      ar[0] -= x.back();
      ar[i] += x.back();
    }
    from.push_back(i);
    to.push_back(0);
    x.push_back(ar[i] / (i + 1));
  }
  for (int i = 1; i < n; i++) {
    from.push_back(0);
    to.push_back(i);
    x.push_back(tot / n);
  }
  printf("%i\n", from.size());
  for (int i = 0; i < ((int)from.size()); i++)
    printf("%i %i %i\n", from[i] + 1, to[i] + 1, x[i]);
}
int main() {
  int t;
  scanf("%i", &t);
  while (t--) doit();
}
