#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int INF = 1e9 + 7;
int T, n, cnt = 0, vl;
int a[N];
struct wt {
  int x, y, z;
} w[N];
void ins(int x, int y, int c) {
  w[++cnt] = (wt){x, y, c};
  a[x] -= x * c;
  a[y] += x * c;
}
struct pir {
  int x, v;
  friend bool operator<(pir a, pir b) { return a.v > b.v; }
};
priority_queue<pir> Q;
bool solve() {
  for (int i = 2; i <= n; i++) Q.push((pir){i, (i - a[i] % i) % i});
  while (!Q.empty()) {
    pir o = Q.top();
    Q.pop();
    if (a[1] < o.v) break;
    if (o.v) ins(1, o.x, o.v);
    ins(o.x, 1, a[o.x] / o.x);
  }
  for (int i = 2; i <= n; i++) {
    if (a[i] != 0 && a[i] != vl) return 0;
    if (!a[i]) ins(1, i, vl);
  }
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int s = 0;
    for (int i = 1; i <= n; i++) s += a[i];
    cnt = 0;
    if (s % n != 0) {
      puts("-1");
      continue;
    }
    vl = s / n;
    bool fl = 1;
    for (int i = 2; i <= n; i++)
      if (a[i] != a[i - 1]) {
        fl = 0;
        break;
      }
    if (fl) {
      puts("0");
      continue;
    }
    int mx = 0;
    for (int i = 2; i <= n; i++)
      if (a[i] >= i) mx = i;
    if (mx) ins(mx, 1, a[mx] / mx);
    if (solve()) {
      printf("%d\n", cnt);
      for (int i = 1; i <= cnt; i++)
        printf("%d %d %d\n", w[i].x, w[i].y, w[i].z);
    } else
      puts("-1");
  }
  return 0;
}
