#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("avx2,fma")
using namespace std;
const int INF = ~(1 << 31);
const double EPS = 1e-9;
const double pi = acos(-1);
template <class T>
T smod(T a, T b) {
  return (a % b + b) % b;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (__typeof(0) i = (0); i < (n); ++i) cin >> a[i];
  int s = 0;
  for (__typeof(0) i = (0); i < (n); ++i) s += a[i];
  if (s % n != 0) {
    cout << -1 << endl;
    return;
  }
  int g = s / n;
  vector<pair<pair<int, int>, int>> op;
  for (__typeof(1) i = (1); i < (n); ++i) {
    int mv = ((i + 1) - a[i] % (i + 1)) % (i + 1);
    op.push_back({{1, i + 1}, mv});
    a[i] += mv;
    a[0] -= mv;
    op.push_back({{i + 1, 1}, a[i] / (i + 1)});
    a[i] -= (i + 1) * (a[i] / (i + 1));
    a[0] += (i + 1) * (a[i] / (i + 1));
  }
  for (__typeof(1) i = (1); i < (n); ++i) {
    op.push_back({{1, i + 1}, g});
  }
  cout << op.size() << endl;
  for (auto x : op) {
    cout << x.first.first << " " << x.first.second << " " << x.second << endl;
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
