#include <bits/stdc++.h>
using namespace std;
long long nmod = 998244353;
const double PI = 3.14159265358979323846;
void solve() {
  long long n, m;
  cin >> n;
  vector<long long> A(n + 1);
  for (long long i = 1; i <= n; i++) cin >> A[i];
  vector<pair<pair<long long, long long>, long long>> ans;
  for (long long i = 2; i <= n; i++) {
    if (A[i] % i == 0) {
      long long x = A[i] / i;
      A[i] = 0;
      A[1] += i * x;
      ans.push_back({{i, 1}, x});
    }
  }
  for (long long i = 2; i <= n; i++) {
    if (A[i] % i) {
      long long k = i - A[i] % i;
      ans.push_back({{1, i}, k});
      A[i] += k;
      A[1] -= k;
      long long x = A[i] / i;
      A[i] = 0;
      A[1] += i * x;
      ans.push_back({{i, 1}, x});
    }
  }
  if (A[1] % n) {
    cout << -1 << endl;
    return;
  }
  for (long long i = 2; i <= n; i++) {
    ans.push_back({{1, i}, A[1] / (n)});
  }
  cout << ans.size() << endl;
  for (auto a : ans)
    cout << a.first.first << " " << a.first.second << " " << a.second << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
