#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    vector<long long> v(n);
    for (auto& x : v) cin >> x;
    long long sum = accumulate(v.begin(), v.end(), 0ll);
    if (sum % n != 0) {
      cout << -1 << '\n';
      continue;
    }
    long long want = sum / (n * 1ll);
    vector<pair<int, pair<int, long long>>> ans;
    for (int i = 1; i < n; i++) {
      if (v[i] % (i + 1) != 0) {
        ans.push_back({1, {i + 1, (i + 1) - (v[i] % (i + 1))}});
        v[0] -= (i + 1) - (v[i] % (i + 1));
        v[i] += (i + 1) - (v[i] % (i + 1));
      }
      assert(v[i] % (i + 1) == 0);
      ans.push_back({i + 1, {1, v[i] / (i + 1)}});
      v[0] += v[i];
      v[i] = 0;
    }
    for (int i = 1; i < n; i++) {
      ans.push_back({1, {i + 1, want}});
    }
    cout << (int)ans.size() << '\n';
    for (auto x : ans) {
      cout << x.first << ' ' << x.second.first << ' ' << x.second.second
           << '\n';
    }
  }
  return 0;
}
