#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 5;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> v(n);
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
  }
  if (sum % n) {
    cout << -1 << endl;
    return;
  }
  long long int t = sum / n;
  vector<vector<long long int>> ans;
  for (long long int i = 1; i < n; i++) {
    if (v[i] % (i + 1)) {
      long long int j = i + 1 - (v[i] % (i + 1));
      ans.push_back(vector<long long int>{1, i + 1, j});
      v[i] += j;
      v[0] -= j;
    }
    ans.push_back(vector<long long int>{i + 1, 1, v[i] / (i + 1)});
    v[0] += v[i];
    v[i] = 0;
  }
  for (long long int i = 1; i < n; i++)
    ans.push_back(vector<long long int>{1, i + 1, t});
  cout << ans.size() << endl;
  for (auto i : ans) {
    cout << i[0] << " " << i[1] << " " << i[2] << endl;
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
