#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 1e5 + 5;
int in[N];
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> in[i];
  int s = accumulate(in + 1, in + 1 + n, 0);
  if (s % n) {
    cout << -1 << "\n";
    return;
  }
  vector<tuple<int, int, int>> ans;
  for (int i = 2; i <= n; i++) {
    if (in[i] % i != 0) {
      int d = i - (in[i] % i);
      if (d > 0) {
        ans.push_back({1, i, d});
        in[1] -= d;
        in[i] += d;
      }
    }
    ans.push_back({i, 1, in[i] / i});
    in[1] += in[i];
    in[i] = 0;
  }
  int avg = s / n;
  for (int i = 2; i <= n; i++) {
    ans.push_back({1, i, avg});
  }
  cout << ans.size() << "\n";
  for (auto& [i, j, x] : ans) cout << i << ' ' << j << ' ' << x << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) solve();
}
