#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
using ll = long long;
using vi = vector<int>;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    vi a(n);
    for (auto &i : a) cin >> i;
    ll sum = 0;
    for (auto i : a) sum += i;
    if (sum % n != 0) {
      cout << -1 << '\n';
      continue;
    }
    ll avg = sum / n;
    vector<pair<pair<int, int>, int>> ans;
    for (int i = 1; i < n; i++) {
      int idx = i + 1;
      int req = ((idx - a[i]) % idx + idx) % idx;
      if (req > 0) {
        ans.push_back(make_pair(make_pair(1, idx), req));
        a[0] -= req;
        a[i] += req;
      }
      if (a[i] > 0) {
        ans.push_back(make_pair(make_pair(idx, 1), a[i] / idx));
        a[0] += a[i];
        a[i] = 0;
      }
    }
    for (int i = 1; i < n; i++) {
      ans.push_back(make_pair(make_pair(1, i + 1), avg));
    }
    cout << int(ans.size()) << '\n';
    for (auto i : ans)
      cout << i.first.first << " " << i.first.second << " " << i.second << '\n';
  }
  return 0;
}
