#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  for (int q = 0; q < t; q++) {
    int n;
    cin >> n;
    vector<int> v(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      sum += v[i];
    }
    if (sum % n != 0) {
      cout << -1 << "\n";
      continue;
    }
    int k = 0;
    vector<tuple<int, int, int>> tp;
    for (int i = 1; i < n; i++) {
      if (v[i] % (i + 1) == 0) {
        k++;
        tp.push_back(make_tuple(i, 0, v[i] / (i + 1)));
        v[0] += v[i];
        v[i] -= v[i];
      } else {
        k++;
        tp.push_back(make_tuple(0, i, i + 1 - v[i] % (i + 1)));
        v[0] -= i + 1 - v[i] % (i + 1);
        v[i] += i + 1 - v[i] % (i + 1);
        k++;
        tp.push_back(make_tuple(i, 0, v[i] / (i + 1)));
        v[0] += v[i];
        v[i] -= v[i];
      }
    }
    for (int i = 1; i < n; i++) {
      k++;
      tp.push_back(make_tuple(0, i, sum / n));
      v[i] += sum / n;
      v[0] -= sum / n;
    }
    cout << k << "\n";
    for (int i = 0; i < tp.size(); i++) {
      cout << get<0>(tp[i]) + 1 << " " << get<1>(tp[i]) + 1 << " "
           << get<2>(tp[i]) << "\n";
    }
  }
  return 0;
}
