#include <bits/stdc++.h>
using namespace std;
void boost() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long power(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
long long sum(long long temp) {
  long long ans = 0;
  while (temp != 0) {
    ans += temp % 10;
    temp /= 10;
  }
  return ans;
}
int main() {
  boost();
  int test = 1, i, j, k = 1;
  cin >> test;
  while (test--) {
    int n;
    cin >> n;
    int ar[n];
    for (i = 0; i < n; i++) cin >> ar[i];
    int ans = 0;
    for (i = 0; i < n; i++) ans += ar[i];
    if (ans % n != 0) {
      cout << -1 << endl;
      continue;
    }
    if (n == 0) {
      cout << 0 << endl;
      continue;
    }
    ans /= n;
    long long st = 0, flag = 0;
    vector<vector<int>> vpp;
    for (i = 1; i < n; i++) {
      j = i + 1;
      int ne = ar[i] % j;
      if (ne != 0) {
        ne = j - ne;
        vpp.push_back({1, j, ne});
        ar[0] -= ne;
        ar[i] += ne;
        st++;
      }
      int x = ar[i] / j;
      ar[i] -= x * j;
      ar[0] += x * j;
      vpp.push_back({j, 1, x});
      st++;
    }
    for (i = 1; i < n; i++) {
      j = i + 1;
      int x = ans - ar[i];
      vpp.push_back({1, j, x});
      st++;
    }
    cout << st << endl;
    for (i = 0; i < st; i++)
      cout << vpp[i][0] << " " << vpp[i][1] << " " << vpp[i][2] << endl;
  }
}
