#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1);
  for (ll i = 1; i <= n; i++) cin >> a[i];
  ll s = accumulate(a.begin(), a.end(), 0LL);
  if (s % n) {
    cout << -1 << '\n';
    return;
  }
  s /= n;
  auto op = [&](ll i, ll j, ll x) {
    a[i] = a[i] - x * i;
    a[j] = a[j] + x * i;
  };
  vector<tuple<ll, ll, ll>> res;
  for (ll i = 2; i <= n; i++) {
    res.emplace_back(1, i, (i - a[i] % i) % i);
    op(1, i, (i - a[i] % i) % i);
    assert(a[1] >= 0);
    assert(a[i] % i == 0);
    res.emplace_back(i, 1, a[i] / i);
    op(i, 1, a[i] / i);
  }
  assert(a[1] == s * n);
  for (ll i = 2; i <= n; i++) {
    res.emplace_back(1, i, s);
    op(1, i, s);
    assert(a[i] == s);
  }
  assert(a[1] == s);
  assert((ll)res.size() <= 3 * n);
  cout << res.size() << '\n';
  for (auto [x, y, z] : res) cout << x << ' ' << y << ' ' << z << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
