#include <bits/stdc++.h>
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end() {}
int n;
long long a[N];
struct op {
  int i, j;
  long long x;
};
vector<op> ans;
inline void solve() {
  scanf("%d", &n);
  ans.resize(0);
  long long sum = 0;
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]), sum += a[i];
  if (sum % n) return puts("-1"), void();
  long long aver = sum / n;
  for (int i = 2; i <= n; ++i) {
    long long cnt = a[i] / i;
    if (a[i] % i == 0) {
      ans.push_back((op){i, 1, a[i] / i});
      a[1] += a[i], a[i] = 0;
      continue;
    }
    cnt++;
    long long cha = 1ll * i * cnt - a[i];
    ans.push_back((op){1, i, cha});
    a[1] -= cha, a[i] += cha;
    assert(a[1] >= 0);
    ans.push_back((op){i, 1, cnt});
    a[1] += 1ll * i * cnt, a[i] -= 1ll * i * cnt;
    assert(a[i] >= 0);
  }
  for (int i = 2; i <= n; ++i) {
    long long cha = aver - a[i];
    ans.push_back((op){1, i, cha});
    a[i] += cha;
    a[1] -= cha;
  }
  cout << ans.size() << '\n';
  for (auto i : ans) printf("%d %d %lld\n", i.i, i.j, i.x);
}
int main() {
  TIME__START = clock();
  int Test = 1;
  scanf("%d", &Test);
  while (Test--) {
    solve();
  }
  TIME__END = clock();
  program_end();
  return 0;
}
