#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
const int inf = 1034567891;
const long long LL_INF = 1234567890123456789ll;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
template <typename T>
T GCD(T a, T b) {
  long long t;
  while (a) {
    t = a;
    a = b % a;
    b = t;
  }
  return b;
}
template <typename T>
string toString(T a) {
  return to_string(a);
}
template <typename T>
void toInt(string s, T& x) {
  stringstream str(s);
  str >> x;
}
inline int add(long long x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline int sub(long long x, long long y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
inline int mul(long long x, long long y) { return (x * 1ll * y) % mod; }
inline long long powr(long long a, long long b) {
  int x = 1 % mod;
  while (b) {
    if (b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline long long inv(long long a) { return powr(a, mod - 2); }
long long Powb(long long b, long long n, long long m) {
  if (n == 0) return 1LL;
  if (n == 1) return b;
  long long temp = Powb(b, n / 2, m);
  if (n % 2 == 0) {
    return (temp * temp) % m;
  } else {
    return (b * ((temp * temp) % m)) % m;
  }
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  ;
  long long sm = 0;
  for (long long i = 0; i < n; i++) {
    sm = sm + v[i];
  }
  if (sm % n != 0) {
    cout << -1 << '\n';
    return;
  }
  long long g = sm / n;
  vector<vector<long long> > ans;
  for (long long i = 1; i < n; i++) {
    long long k = v[i] % (i + 1);
    ans.push_back({1, i + 1, (i + 1 - (k)) % (i + 1)});
    ans.push_back({i + 1, 1, (v[i] + ((i + 1) - (k)) % (i + 1)) / (i + 1)});
    v[0] = v[0] + k;
  }
  for (long long i = 1; i < n; i++) {
    ans.push_back({1, i + 1, g});
  }
  cout << ans.size() << '\n';
  for (auto x : ans) {
    cout << x[0] << " " << x[1] << " " << x[2] << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  cin >> t;
  while (t--) solve();
}
