#include <bits/stdc++.h>
using namespace std;
const long long maxm = 1e4 + 5;
struct Node {
  long long i, j, x;
};
vector<Node> ans;
long long a[maxm];
long long n;
void solve() {
  ans.clear();
  cin >> n;
  long long sum1 = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    sum1 += a[i];
  }
  if (sum1 % n) {
    cout << -1 << endl;
    return;
  }
  long long ave = sum1 / n;
  for (long long i = 2; i <= n; i++) {
    long long t = a[i] % i;
    if (t) t = i - t;
    ans.push_back({1, i, t});
    a[i] += t;
    a[1] -= t;
    ans.push_back({i, 1, a[i] / i});
    a[1] += a[i];
    a[i] = 0;
  }
  for (long long i = 2; i <= n; i++) {
    ans.push_back({1, i, ave});
    a[i] += ave;
    a[1] -= ave;
  }
  cout << ans.size() << endl;
  for (auto i : ans) {
    cout << i.i << ' ' << i.j << ' ' << i.x << endl;
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
