#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 2e5 + 22;
struct node {
  int p, q, x;
};
int T, n, a[maxn];
vector<node> v;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    int sum = 0;
    v.clear();
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      sum += a[i];
    }
    if (sum % n != 0) {
      puts("-1");
    } else {
      int g = sum / n;
      for (int i = 2; i <= n; i++) {
        if (a[i] % i) {
          v.push_back(node{1, i, i - a[i] % i});
          a[1] -= (i - a[i] % i);
          a[i] += (i - a[i] % i);
        }
        v.push_back(node{i, 1, a[i] / i});
        a[1] += a[i];
        a[i] = 0;
      }
      for (int i = 2; i <= n; i++) {
        v.push_back(node{1, i, g});
      }
      printf("%d\n", (int)v.size());
      for (auto nd : v) {
        printf("%d %d %d\n", nd.p, nd.q, nd.x);
      }
    }
  }
  return 0;
}
