#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
mt19937 rnd(time(nullptr));
const int N = 1e4 + 5;
long long a[N];
void solve() {
  int n;
  cin >> n;
  long long res = 0;
  for (int i = 1; i <= n; ++i) cin >> a[i], res += a[i];
  if (res % n) {
    cout << "-1\n";
    return;
  }
  res /= n;
  vector<pair<pair<int, int>, long long>> ans;
  for (int i = 2; i <= n; ++i) {
    long long r = (i - a[i] % i) % i;
    ans.push_back({{1, i}, r});
    a[i] += r, a[1] -= r;
    ans.push_back({{i, 1}, a[i] / i});
    a[1] += a[i], a[i] = 0;
  }
  for (int i = 2; i <= n; ++i) {
    ans.push_back({{1, i}, res});
    a[1] -= res, a[i] = res;
  }
  cout << ans.size() << "\n";
  for (auto cur : ans)
    cout << cur.first.first << " " << cur.first.second << " " << cur.second
         << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
