#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * f;
}
const int N = 1e4 + 5;
int n, sum, a[N];
void solve() {
  n = read();
  sum = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    sum = sum + a[i];
  }
  if (sum % n) {
    printf("-1\n");
    return;
  }
  sum = sum / n;
  printf("%d\n", 3 * (n - 1));
  for (int i = 2; i <= n; i++) {
    int x = a[i] % i;
    printf("1 %d %d\n", i, (i - x) % i);
    a[1] = a[1] - (i - x) % i;
    a[i] = a[i] + (i - x) % i;
    printf("%d 1 %d\n", i, a[i] / i);
    a[1] += a[i];
    a[i] = 0;
  }
  for (int i = 2; i <= n; i++) {
    printf("1 %d %d\n", i, sum);
    a[1] -= sum;
    a[i] += sum;
  }
}
int main() {
  int T = read();
  while (T--) solve();
  return 0;
}
