#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 5;
const int inf = 0x3f3f3f3f;
const int modu = 1e9 + 7;
int a[maxn], n;
vector<int> op[3];
int main() {
  int T;
  cin >> T;
  while (T--) {
    int sum = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
      sum += a[i];
    }
    if (sum % n != 0) {
      printf("-1\n");
      continue;
    }
    op[0].clear();
    op[1].clear();
    op[2].clear();
    for (int i = 2; i <= n; ++i) {
      if (a[i] % i != 0) {
        op[0].push_back(1);
        op[1].push_back(i);
        op[2].push_back(i - (a[i] % i));
        a[1] -= (i - (a[i] % i));
        a[i] += (i - (a[i] % i));
      }
      op[0].push_back(i);
      op[1].push_back(1);
      op[2].push_back(a[i] / i);
      a[1] += a[i];
      a[i] = 0;
    }
    for (int i = 2; i <= n; ++i) {
      op[0].push_back(1);
      op[1].push_back(i);
      op[2].push_back(sum / n);
    }
    printf("%d\n", op[0].size());
    for (int i = 0; i < op[0].size(); ++i)
      printf("%d %d %d\n", op[0][i], op[1][i], op[2][i]);
  }
  return 0;
}
