#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 7;
int a[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    long long sm = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sm += a[i];
    }
    vector<int> x, y, z;
    if (sm % n != 0) {
      cout << "-1" << endl;
      continue;
    }
    sm = sm / n;
    for (int i = 2; i <= n; i++) {
      int need = (i - (a[i] % i)) % i;
      if (need > 0) {
        x.push_back(1);
        y.push_back(i);
        z.push_back(need);
        a[1] -= need;
        a[i] += need;
      }
      x.push_back(i);
      y.push_back(1);
      z.push_back(a[i] / i);
      a[1] += a[i];
      a[i] = 0;
    }
    for (int i = 2; i <= n; i++) {
      x.push_back(1);
      y.push_back(i);
      z.push_back(sm);
      a[1] -= sm;
      a[i] += sm;
    }
    cout << (int)x.size() << endl;
    for (int i = 0; i < (int)x.size(); i++) {
      cout << x[i] << " " << y[i] << " " << z[i] << endl;
    }
  }
}
