#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long sum = 0;
    vector<long long> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
    if (sum % n != 0) {
      cout << -1 << "\n";
      continue;
    }
    long long v = sum / n;
    vector<vector<int>> ans;
    auto op = [&](int i, int j, int x) {
      ans.push_back({i, j, x});
      a[i] -= x * i;
      a[j] += x * i;
    };
    for (int i = 2; i <= n; i++) {
      if (a[i] % i) op(1, i, i - a[i] % i);
      op(i, 1, a[i] / i);
    }
    for (int i = 2; i <= n; i++) op(1, i, v);
    cout << ans.size() << "\n";
    for (auto zz : ans) {
      for (auto xx : zz) cout << xx << " ";
      cout << "\n";
    }
  }
}
