#include <bits/stdc++.h>
using namespace std;
int T;
int n, a[10007];
struct ope {
  int x, y, k;
} o[10007 * 5];
int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    int sum = 0;
    for (register int i = 1; i <= n; ++i) {
      scanf("%d", a + i);
      sum += a[i];
    }
    if (sum % n) {
      cout << -1 << endl;
      continue;
    }
    int t = 0;
    for (register int i = 2; i <= n; ++i) {
      if (a[i] % i) {
        o[++t].x = 1;
        o[t].y = i;
        o[t].k = i - a[i] % i;
        a[1] -= o[t].k;
        a[i] += i - a[i] % i;
      }
      o[++t].x = i;
      o[t].y = 1;
      a[1] += a[i];
      o[t].k = a[i] / i;
    }
    int ave = sum / n;
    for (register int i = 2; i <= n; ++i) {
      o[++t].x = 1;
      o[t].y = i;
      o[t].k = ave;
    }
    cout << t << endl;
    for (register int i = 1; i <= t; ++i) {
      printf("%d %d %d\n", o[i].x, o[i].y, o[i].k);
    }
  }
  return 0;
}
