#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5 + 5;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  vector<int> v(n + 1);
  int sum = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> v[i];
    sum += v[i];
  }
  if (sum % n != 0) {
    cout << -1 << '\n';
    return;
  }
  vector<array<int, 3> > ans;
  int x = sum / n;
  for (int i = 2; i <= n; i++) {
    if (v[i] % i == 0) {
      ans.push_back({i, 1, v[i] / i});
    } else {
      ans.push_back({1, i, i - (v[i] % i)});
      ans.push_back({i, 1, v[i] / i + 1});
    }
  }
  for (int i = 2; i <= n; i++) {
    ans.push_back({1, i, x});
  }
  cout << ans.size() << '\n';
  for (auto x : ans) {
    cout << x[0] << " " << x[1] << " " << x[2] << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
