#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int t, n, a[N], sum, tot;
struct Node {
  int i, j, x;
} ans[3 * N];
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    sum = 0;
    tot = 0;
    for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
    if (sum % n != 0) {
      cout << "-1\n";
      continue;
    }
    sum = sum / n;
    for (int i = 2; i <= n; i++) {
      if (a[i] % i == 0) ans[++tot] = {i, 1, a[i] / i};
    }
    for (int i = 2; i <= n; i++) {
      if (a[i] % i != 0) {
        ans[++tot] = {1, i, i - a[i] % i};
        a[i] += (i - a[i] % i);
        ans[++tot] = {i, 1, a[i] / i};
        a[i] = 0;
      }
    }
    for (int i = 2; i <= n; i++) ans[++tot] = {1, i, sum};
    cout << tot << endl;
    for (int i = 1; i <= tot; i++)
      cout << ans[i].i << " " << ans[i].j << " " << ans[i].x << endl;
  }
  return 0;
}
