#include <bits/stdc++.h>
template <class T>
T read(T &a) {
  a = 0;
  char x = getchar();
  bool f = 0;
  for (; x < '0' || x > '9'; x = getchar()) f |= x == '-';
  for (; x >= '0' && x <= '9'; x = getchar()) a = (a << 3) + (a << 1) + x - '0';
  if (f) a = -a;
  return a;
}
using namespace std;
int d[10050];
int main() {
  int T;
  read(T);
  while (T--) {
    int n;
    read(n);
    int tot = 0;
    for (int i = 1; i <= n; ++i) {
      read(d[i]);
      tot += d[i];
    }
    if (tot % n) {
      puts("-1");
      continue;
    }
    int req = tot / n;
    printf("%d\n", 3 * n - 3);
    for (int i = 2; i <= n; ++i) {
      printf("%d %d %d\n", 1, i, (i - d[i] % i) % i);
      d[i] += (i - d[i] % i) % i;
      printf("%d %d %d\n", i, 1, d[i] / i);
    }
    for (int i = 2; i <= n; ++i) {
      printf("%d %d %d\n", 1, i, req);
    }
  }
  return 0;
}
