#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<long long> a;
  long long s = 0;
  for (int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    a.push_back(x);
    s += x;
  }
  if (s % (long long)n == 0) {
    long long target = s / n;
    vector<pair<int, pair<int, int> > > ans;
    for (int i = 1; i < n; ++i) {
      long long x = (i + 1 - (a[i] % (i + 1))) % (i + 1);
      ans.push_back(make_pair(1, pair<int, int>(i + 1, x)));
      a[i] += x;
      a[0] -= x;
      x = a[i] / (i + 1);
      ans.push_back(make_pair(i + 1, pair<int, int>(1, x)));
      a[i] -= x * (i + 1);
      a[0] += x * (i + 1);
    }
    for (int i = 1; i < n; ++i) {
      ans.push_back(make_pair(1, pair<int, int>(i + 1, target)));
      a[0] -= target;
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); ++i)
      cout << ans[i].first << ' ' << ans[i].second.first << ' '
           << ans[i].second.second << '\n';
  } else {
    cout << -1 << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
