#include <bits/stdc++.h>
using namespace std;
struct Data {
  long long i, j, x;
};
signed main() {
  ios::sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v{0};
    long long sum = 0;
    for (long long i = 1; i <= n; i++) {
      long long x;
      cin >> x;
      sum += x;
      v.push_back(x);
    }
    if (sum % n != 0) {
      cout << -1 << endl;
      continue;
    }
    long long avg = sum / n;
    vector<Data> u;
    for (long long i = 2; i <= n; ++i) {
      if (v[i] % i == 0)
        u.push_back(Data{i, 1, v[i] / i});
      else {
        long long r = i - v[i] % i;
        u.push_back(Data{1, i, r});
        v[i] += r;
        u.push_back(Data{i, 1, v[i] / i});
      }
    }
    for (long long i = 2; i <= n; ++i) {
      u.push_back(Data{1, i, avg});
    }
    cout << u.size() << endl;
    for (auto e : u) {
      cout << e.i << " " << e.j << " " << e.x << endl;
    }
  }
  return 0;
}
