#include <bits/stdc++.h>
template <class T>
void ckmin(T& a, const T& b) {
  a = b < a ? b : a;
}
template <class T>
void ckmax(T& a, const T& b) {
  a = b > a ? b : a;
}
template <class T>
void readvec(std::vector<T>& v, const int n) {
  for (int i = 0; i < n; i++) {
    T p;
    std::cin >> p;
    v.push_back(p);
  }
}
using namespace std;
const int maxn = 200005;
void solve() {
  long long n;
  cin >> n;
  vector<long long> v;
  readvec(v, n);
  long long sum = 0;
  for (long long x : v) {
    sum += x;
  }
  if (sum % n != 0) {
    cout << -1 << endl;
    return;
  }
  vector<pair<pair<int, int>, int> > ara;
  for (int i = 1; i < n; i++) {
    long long now = v[1];
    long long next = v[i];
    if (next % (i + 1) != 0) {
      ara.push_back({{1, i + 1}, (i + 1) - (v[i] % (i + 1))});
      next += (i + 1) - (v[i] % (i + 1));
      v[0] -= (i + 1) - (v[i] % (i + 1));
      v[i] = next;
    }
    ara.push_back({{i + 1, 1}, v[i] / (i + 1)});
    v[0] += v[i];
    v[i] = 0;
  }
  for (int i = 1; i < n; i++) {
    ara.push_back({{1, i + 1}, sum / n});
  }
  cout << ara.size() << endl;
  for (auto x : ara) {
    cout << x.first.first << " " << x.first.second << " " << x.second << endl;
  }
}
int main() {
  int t, cas = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
