#include <bits/stdc++.h>
using namespace std;
void test_cases() {
  int n, sum = 0;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum % n != 0) {
    cout << "-1\n";
    return;
  }
  int m = sum / n;
  vector<int> x, y, z;
  for (int i = 2; i <= n; i++) {
    int j = (i - a[i] % i) % i;
    if (j > 0) {
      x.push_back(1);
      y.push_back(i);
      z.push_back(j);
    }
    a[i] += j;
    a[1] -= j;
    x.push_back(i);
    y.push_back(1);
    z.push_back(a[i] / i);
    a[1] += a[i];
    a[i] -= a[i];
  }
  for (int i = 2; i <= n; i++) {
    x.push_back(1);
    y.push_back(i);
    z.push_back(m);
    a[i] += m;
    a[1] -= m;
  }
  cout << x.size() << "\n";
  for (int i = 0; i < (int)x.size(); i++) {
    cout << x[i] << " " << y[i] << " " << z[i] << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tt;
  cin >> tt;
  while (tt--) {
    test_cases();
  }
  return 0;
}
