#include <bits/stdc++.h>
using namespace std;
const int MX = 1e4 + 5;
vector<long long> pi, pj, x;
long long ara[MX];
void perform(long long i, long long j, long long v) {
  pi.push_back(i + 1);
  pj.push_back(j + 1);
  x.push_back(v);
  ara[i] -= v * (i + 1);
  ara[j] += v * (i + 1);
}
int main() {
  long long i, j, k;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long sm = 0;
    for (i = 0; i < n; ++i) {
      cin >> ara[i];
      sm += ara[i];
    }
    if (sm % n) {
      puts("-1");
      continue;
    }
    for (i = 1; i < n; ++i) {
      long long req;
      if (ara[i] % (i + 1)) {
        req = ara[i] % (i + 1);
        req = (i + 1 - req) % (i + 1);
        perform(0, i, req);
      }
      perform(i, 0, ara[i] / (i + 1));
    }
    for (i = 1; i < n; ++i) perform(0, i, sm / n);
    assert(x.size() <= 3 * n && ara[0] == sm / n);
    cout << x.size() << endl;
    for (i = 0; i < x.size(); ++i) {
      cout << pi[i] << " " << pj[i] << " " << x[i] << endl;
    }
    pi.clear();
    pj.clear();
    x.clear();
  }
}
