#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int inf = (1 << 30) - 1;
const ll INF = (1LL << 60) - 1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template <typename T>
bool chmax(T &x, const T &y) {
  return (x < y) ? (x = y, true) : false;
};
template <typename T>
bool chmin(T &x, const T &y) {
  return (x > y) ? (x = y, true) : false;
};
struct query {
  int i, j, x;
  query(int i, int j, int x) : i(i), j(j), x(x) {}
};
int main() {
  int T;
  cin >> T;
  while (T--) {
    int N;
    cin >> N;
    ll a[N + 1], s = 0;
    for (int i = 1; i <= N; i++) {
      cin >> a[i];
      s += a[i];
    }
    if (s % N != 0) {
      cout << -1 << endl;
      continue;
    }
    int k = s / N;
    vector<query> ans;
    for (int i = 2; i <= N; i++) {
      if (a[i] % i == 0) {
        ans.emplace_back(i, 1, a[i] / i);
      } else {
        ans.emplace_back(1, i, i - (a[i] % i));
        ans.emplace_back(i, 1, 1 + a[i] / i);
      }
    }
    for (int i = 2; i <= N; i++) {
      ans.emplace_back(1, i, k);
    }
    cout << (int)ans.size() << endl;
    for (auto &e : ans) {
      cout << e.i << ' ' << e.j << ' ' << e.x << endl;
    }
  }
}
