#include <bits/stdc++.h>
using namespace std;
ifstream fin("input");
void init() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
}
struct operation {
  int i, j, x;
};
int n;
vector<int> v;
vector<int> cpy;
vector<operation> ops;
void simul() {
  for (operation x : ops) {
    cpy[x.i] -= x.i * x.x;
    cpy[x.j] += x.i * x.x;
  }
  for (int i = 1; i <= n; i++) cout << cpy[i] << " ";
  cout << endl;
}
void read() {
  cin >> n;
  v.resize(n + 1);
  for (int i = 1; i <= n; i++) cin >> v[i];
  cpy = v;
}
void solve() {
  int sum = 0;
  for (int i = 1; i <= n; i++) sum += v[i];
  if (sum % n != 0) {
    cout << -1 << endl;
    return;
  }
  for (int i = 2; i <= n; i++) {
    if (v[i] != 0) {
      int remaining = v[i] % i;
      if (remaining) {
        int required = i - remaining;
        ops.push_back({1, i, required});
        v[i] += required;
      }
      ops.push_back({i, 1, v[i] / i});
    }
  }
  for (int i = 2; i <= n; i++) {
    ops.push_back({1, i, sum / n});
  }
  cout << ops.size() << endl;
  for (operation& x : ops) {
    cout << x.i << " " << x.j << " " << x.x << endl;
  }
  ops.clear();
}
int main() {
  init();
  int t;
  cin >> t;
  while (t--) {
    read();
    solve();
  }
  return 0;
}
