#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
int t, n;
long long a[N];
int32_t main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      sum += a[i];
    }
    if (sum % n != 0) {
      printf("%d\n", -1);
    } else {
      sum /= (long long)n;
      vector<array<long long, 3> > op;
      for (int i = 2; i <= n; i++) {
        if (a[i] % i) {
          int r = i - (a[i] % i);
          op.push_back({1, i, r});
          a[1] -= r;
          a[i] += r;
        }
        op.push_back({i, 1, a[i] / i});
      }
      for (int i = 2; i <= n; i++) {
        op.push_back({1, i, sum});
      }
      printf("%d\n", (int)(op).size());
      for (auto w : op) {
        printf("%lld %lld %lld\n", w[0], w[1], w[2]);
      }
      printf("\n");
    }
  }
}
