#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
using namespace std;
inline long long in() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const long long N = 1e4 + 5;
long long a[N];
struct q {
  long long i;
  long long j;
  long long x;
};
vector<tuple<long long, long long, long long>> mv;
void trans(long long from, long long to, long long amount) {
  long long x = amount / from;
  mv.push_back({from, to, x});
  assert(amount <= a[from]);
  a[from] -= amount;
  a[to] += amount;
}
void solve() {
  long long n = in();
  for (long long i = 1; i <= n; i++) a[i] = in();
  long long sum = accumulate(a + 1, a + n + 1, 0LL);
  if (sum % n != 0) {
    puts("-1");
    return;
  }
  mv = vector<tuple<long long, long long, long long>>();
  long long final = sum / n;
  for (long long i = 2; i <= n; i++) {
    if (a[i] % i) trans(1, i, i - a[i] % i);
    trans(i, 1, a[i]);
  }
  for (long long i = 2; i <= n; i++) {
    trans(1, i, final);
  }
  cout << mv.size() << "\n";
  for (auto v : mv) {
    long long i, j, x;
    tie(i, j, x) = v;
    cout << i << " " << j << " " << x << "\n";
  }
}
int32_t main() {
  long long t = in();
  while (t--) solve();
}
