#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, ans = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + c - '0';
    c = getchar();
  }
  return f * ans;
}
const int MAXN = 1e4 + 11;
int T, N, A[MAXN], sum, tot;
pair<pair<int, int>, int> Ans[MAXN << 2];
int main() {
  T = read();
  while (T--) {
    N = read(), sum = 0;
    for (int i = 1; i <= N; i++) A[i] = read(), sum += A[i];
    tot = 0;
    if ((sum % N)) {
      printf("-1\n");
      continue;
    }
    sum /= N;
    for (int i = 2; i <= N; i++) {
      int x = (i - (A[i] % i)) % i;
      ++tot;
      Ans[tot].first.first = 1, Ans[tot].first.second = i, Ans[tot].second = x;
      ++tot;
      Ans[tot].first.first = i, Ans[tot].first.second = 1,
      Ans[tot].second = (x + A[i]) / i;
    }
    for (int i = 2; i <= N; i++) {
      ++tot;
      Ans[tot].first.first = 1, Ans[tot].first.second = i,
      Ans[tot].second = sum;
    }
    printf("%d\n", tot);
    for (int i = 1; i <= tot; i++)
      printf("%d %d %d\n", Ans[i].first.first, Ans[i].first.second,
             Ans[i].second);
  }
  return 0;
}
