#include <bits/stdc++.h>
const int MaxN = 1e4 + 5;
using namespace std;
long long int t, n, m, a[MaxN];
struct event {
  int ii, jj;
  long long int xx;
};
event e[4 * MaxN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> t;
  while (t--) {
    cin >> n;
    long long int s = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      s += a[i];
    }
    if (s % n != 0) {
      cout << -1 << "\n";
      continue;
    }
    long long int c = 0;
    long long int avg = s / n;
    for (int i = 2; i <= n; i++) {
      if (a[i] % i) {
        e[c].ii = 1;
        e[c].jj = i;
        e[c].xx = i - a[i] % i;
        c++;
        a[1] = a[1] - (i - a[i] % i);
        a[i] = a[i] + (i - a[i] % i);
      }
      e[c].ii = i;
      e[c].jj = 1;
      e[c].xx = a[i] / i;
      c++;
      a[i] = 0;
      a[1] = a[1] + a[i];
    }
    for (int i = 2; i <= n; i++) {
      e[c].ii = 1;
      e[c].jj = i;
      e[c].xx = avg;
      c++;
    }
    cout << c << "\n";
    for (int i = 0; i < c; i++) {
      cout << e[i].ii << " " << e[i].jj << " " << e[i].xx << "\n";
    }
  }
  return 0;
}
