#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  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) {
    cout << -1 << "\n";
    return;
  }
  vector<tuple<long long, long long, long long>> v;
  for (long long i = 2; i <= n; i++) {
    long long r = a[i] % i;
    if (a[i] == 0) continue;
    if (r) {
      v.push_back(make_tuple(1, i, (i - r)));
      a[i] += (i - r);
      a[1] -= (i - r);
    }
    v.push_back(make_tuple(i, 1, a[i] / (i)));
    a[1] += a[i];
    a[i] = 0;
  }
  for (long long i = 2; i <= n; i++) {
    v.push_back(make_tuple(1, i, a[1] / n));
  }
  cout << v.size() << "\n";
  for (long long i = 0; i < v.size(); i++) {
    cout << get<0>(v[i]) << " " << get<1>(v[i]) << " " << get<2>(v[i]) << "\n";
  }
  return;
}
int main() {
  int t;
  t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
