#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int total = 0;
  for (int i = 0; i < n; i++) total += a[i];
  if (total % n != 0) {
    cout << -1 << '\n';
    return;
  }
  int target = total / n;
  vector<vector<int>> moves;
  for (int i = 1; i < n; i++) {
    int diff = (i + 1 - a[i] % (i + 1)) % (i + 1);
    a[0] -= diff;
    a[i] += diff;
    moves.push_back({0, i, diff});
    diff = a[i];
    a[i] -= diff;
    a[0] += diff;
    moves.push_back({i, 0, diff / (i + 1)});
  }
  for (int i = 1; i < n; i++) {
    int diff = target;
    a[0] -= diff;
    a[i] += diff;
    moves.push_back({0, i, diff});
  }
  cout << moves.size() << '\n';
  for (auto v : moves)
    cout << v[0] + 1 << " " << v[1] + 1 << " " << v[2] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
}
