#include <bits/stdc++.h>
using namespace std;
const bool debug = 0;
struct mout {
  int i, j;
  long long first;
  mout(){};
  mout(int i, int j, long long first) : i(i), j(j), first(first) {}
};
int main() {
  if (!debug) {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<long long> a(n);
    vector<mout> out;
    for (int i = 0; i < n; i++) cin >> a[i];
    long long s = 0;
    for (int i = 0; i < n; i++) s += a[i];
    if (s != (s / n) * n) {
      cout << "-1\n";
      continue;
    }
    s /= n;
    for (int i = 1; i < n; i++) {
      if (a[i] % (i + 1) != 0) {
        out.push_back({1, i + 1, i + 1 - a[i] % (i + 1)});
        a[1] -= i + 1 - a[i] % (i + 1);
        a[i] += i + 1 - a[i] % (i + 1);
      }
      out.push_back({i + 1, 1, a[i] / (i + 1)});
      a[1] += a[i];
      a[i] = 0;
    }
    for (int i = 1; i < n; i++) {
      out.push_back({1, i + 1, s});
    }
    cout << out.size() << '\n';
    for (int i = 0; i < out.size(); i++)
      cout << out[i].i << ' ' << out[i].j << ' ' << out[i].first << '\n';
  }
  return 0;
}
