#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int maxn = 1e5 + 5;
int n, m;
int a[maxn];
struct node {
  int x, y, l;
};
int main() {
  int T;
  cin >> T;
  while (T--) {
    vector<node> ans;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    if (sum % n) {
      printf("-1\n");
      continue;
    }
    for (int i = 2; i <= n; i++) {
      if (a[i] % i == 0) {
        ans.push_back({i, 1, a[i] / i});
      } else {
        int t = i - (a[i] % i);
        ans.push_back({1, i, t});
        ans.push_back({i, 1, (a[i] + t) / i});
      }
    }
    for (int i = 2; i <= n; i++) {
      ans.push_back({1, i, sum / n});
    }
    printf("%d\n", (int)ans.size());
    for (int i = 0; i < ans.size(); i++) {
      printf("%d %d %d\n", ans[i].x, ans[i].y, ans[i].l);
    }
  }
  return 0;
}
