#include <bits/stdc++.h>
const int MAXN = 10005;
int a[MAXN];
void operate(int i, int j, int x) {
  a[i] -= i * x, a[j] += i * x;
  printf("%d %d %d\n", i, j, x);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, sum = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum += a[i];
    if (sum % n != 0) {
      puts("-1");
      continue;
    }
    sum /= n;
    printf("%d\n", 3 * n - 3);
    for (int i = 2; i <= n; i++)
      operate(1, i, (i - a[i] % i) % i), operate(i, 1, a[i] / i);
    for (int i = 2; i <= n; i++) operate(1, i, sum);
  }
  return 0;
}
