#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
void solve() {
  int n;
  cin >> n;
  VI a(n + 1);
  int s = 0;
  for (int i = (1); i < (n + 1); ++i) {
    cin >> a[i];
    s += a[i];
  }
  if (s % n != 0) {
    cout << -1 << "\n";
    return;
  }
  vector<tuple<int, int, int>> ans;
  auto op = [&](int i, int j, int x) {
    ans.emplace_back(i, j, x);
    a[i] -= i * x;
    a[j] += i * x;
    assert(a[i] >= 0);
  };
  for (int i = (2); i < (n + 1); ++i) {
    if (a[i] % i != 0) {
      op(1, i, i - (a[i] % i));
    }
    assert(a[i] % i == 0);
    op(i, 1, a[i] / i);
    assert(a[i] == 0);
  }
  for (int i = (2); i < (n + 1); ++i) {
    op(1, i, s / n);
  }
  for (int i = (1); i < (n + 1); ++i) assert(a[i] == s / n);
  cout << (int)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();
  return 0;
}
