#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sum = accumulate(a.begin(), a.end(), 0ll);
  if (sum % n) {
    cout << "-1\n";
    return;
  }
  int x = sum / n;
  bool eq = 1;
  for (int i = 0; i < n; i++) {
    eq &= x == a[i];
  }
  if (eq) {
    cout << "0\n";
    return;
  }
  vector<vector<int>> ans;
  auto go = [&](int i, int j, int w) {
    assert(a[i] >= w * (i + 1));
    a[i] -= w * (i + 1);
    a[j] += w * (i + 1);
    ans.push_back({i, j, w});
  };
  for (int i = 1; i < n; i++) {
    int r = a[i] % (i + 1);
    if (r != 0) {
      go(0, i, i + 1 - r);
    }
    go(i, 0, a[i] / (i + 1));
  }
  for (int i = 1; i < n; i++) {
    go(0, i, x);
  }
  for (int i = 0; i < n; i++) {
    assert(a[i] == x);
  }
  assert((int)ans.size() <= 3 * n);
  cout << (int)ans.size() << '\n';
  for (auto i : ans) {
    cout << i[0] + 1 << ' ' << i[1] + 1 << ' ' << i[2] << '\n';
  }
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    solve();
  }
}
