#include <bits/stdc++.h>
using namespace std;
const long long MAX = (long long)1e6 + 10;
long long inf = (long long)1e15;
long long n, x;
void solve() {
  cin >> n;
  vector<long long> a(n + 1, 0), pos(n + 1, 0);
  long long need = 0;
  vector<pair<pair<long long, long long>, long long>> ans;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[i] = a[i];
    need += a[i];
  }
  if (need % n != 0) {
    cout << -1 << "\n";
    return;
  }
  need /= n;
  vector<pair<long long, long long>> inds;
  long long ind = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] >= i) ind = i;
  }
  for (int i = ind + 1; i <= n; i++) {
    inds.push_back({i - a[i], i});
  }
  if (ind != 1) {
    ans.push_back({{ind, 1}, 1});
    a[ind] -= ind;
    a[1] += ind;
  }
  for (int i = 2; i <= ind; i++) {
    ans.push_back({{1, i}, i - a[i] % i});
    ans.push_back({{i, 1}, a[i] / i + 1});
    a[1] += a[i];
  }
  sort(inds.begin(), inds.end());
  for (int i = 0; i < inds.size(); i++) {
    if (inds[i].first > a[1]) {
      cout << -1 << "\n";
      return;
    } else {
      ans.push_back({{1, inds[i].second}, inds[i].first});
      ans.push_back({{inds[i].second, 1},
                     (a[inds[i].second] + inds[i].first) / inds[i].second});
      a[1] += a[inds[i].second];
    }
  }
  for (int i = 2; i <= n; i++) {
    ans.push_back({{1, i}, need});
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first.first << " " << ans[i].first.second << " "
         << ans[i].second << "\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  long long q;
  cin >> q;
  while (q--) solve();
  return 0;
}
