#include <bits/stdc++.h>
using namespace std;
int q, n, v[10100];
int main() {
  cin >> q;
  while (q--) {
    vector<pair<pair<int, int>, int>> operatii;
    int suma = 0, want;
    bool ok = true;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> v[i];
      suma += v[i];
    }
    want = suma / n;
    if (want * n != suma) ok = false;
    set<pair<int, int>> to_complete;
    for (int i = 2; i <= n; i++) {
      if (v[i] % i == 0) {
        operatii.push_back(make_pair(make_pair(i, 1), v[i] / i));
        v[1] += i;
        v[i] = 0;
      } else
        to_complete.insert(make_pair(i - v[i] % i, i));
    }
    for (pair<int, int> p : to_complete) {
      if (v[1] < p.first) {
        ok = false;
        break;
      }
      operatii.push_back(make_pair(make_pair(1, p.second), p.first));
      v[1] -= p.first;
      v[p.second] += p.first;
      operatii.push_back(
          make_pair(make_pair(p.second, 1), v[p.second] / p.second));
      v[1] += v[p.second];
      v[p.second] -= v[p.second];
    }
    if (!ok) {
      cout << -1 << '\n';
      continue;
    }
    for (int i = 2; i <= n; i++)
      operatii.push_back(make_pair(make_pair(1, i), want));
    cout << operatii.size() << '\n';
    for (pair<pair<int, int>, int> op : operatii)
      cout << op.first.first << ' ' << op.first.second << ' ' << op.second
           << '\n';
  }
}
