#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 50;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
struct sa {
  long long i, j, x;
};
int a[MAXN];
vector<sa> ans;
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long t, n;
  cin >> t;
  while (t--) {
    ans.clear();
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
    if (sum % n) {
      cout << -1 << endl;
      continue;
    }
    for (int i = 2; i <= n; i++) {
      if (a[i] % i == 0) {
        sa k = {i, 1, a[i] / i};
        ans.push_back(k);
      } else {
        sa k = {1, i, i - a[i] % i};
        ans.push_back(k);
        sa kk = {i, 1, a[i] / i + 1};
        ans.push_back(kk);
      }
    }
    for (int i = 2; i <= n; i++) {
      sa k = {1, i, sum / n};
      ans.push_back(k);
    }
    int len = ((int)(ans).size());
    cout << len << endl;
    for (int i = 0; i < len; i++)
      cout << ans[i].i << " " << ans[i].j << " " << ans[i].x << endl;
  }
  return 0;
}
