#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  long long sum = 0;
  for (long long i = 1; i <= n; ++i) cin >> a[i], sum += a[i];
  if (sum % n == 0) {
    vector<tuple<long long, long long, long long>> ope;
    for (long long i = 2; i <= n; ++i) {
      long long need = (i - (a[i] % i)) % i;
      assert(a[1] >= need);
      ope.push_back(make_tuple(1, i, need));
      a[1] -= need, a[i] += need;
      assert(a[i] % i == 0);
      ope.push_back(make_tuple(i, 1, a[i] / i));
      a[1] += a[i], a[i] = 0;
    }
    for (long long i = 2; i <= n; ++i) {
      ope.push_back(make_tuple(1, i, sum / n));
    }
    cout << (long long)(ope).size() << '\n';
    for (auto u : ope)
      cout << get<0>(u) << ' ' << get<1>(u) << ' ' << get<2>(u) << '\n';
  } else {
    cout << -1;
  }
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
