#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000000000000000;
struct dstv {
  long long in, jn, x;
};
long long t, n, a[10005], sum, tmp;
vector<dstv> ans;
dstv p;
pair<long long, long long> pa;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  for (long long o = 1; o <= t; ++o) {
    cin >> n;
    sum = 0;
    ans.clear();
    for (long long i = 1; i <= n; ++i) {
      cin >> a[i];
      sum += a[i];
    }
    if (sum % n != 0) {
      cout << -1 << '\n';
      continue;
    }
    for (long long i = 2; i <= n; ++i) {
      if (a[i] % i == 0) {
        p.in = i;
        p.jn = 1;
        p.x = (a[i] / i);
        ans.push_back(p);
        a[1] += a[i];
        a[i] = 0;
        continue;
      }
      tmp = (i - (a[i] % i)) % i;
      p.in = 1;
      p.jn = i;
      p.x = tmp;
      a[1] -= tmp;
      a[i] += tmp;
      ans.push_back(p);
      p.in = i;
      p.jn = 1;
      p.x = (a[i] / i);
      a[1] += a[i];
      a[i] = 0;
      ans.push_back(p);
    }
    for (long long i = 2; i <= n; ++i) {
      p.in = 1;
      p.jn = i;
      p.x = (sum / n);
      a[i] = (sum / n);
      a[1] -= (sum / n);
      ans.push_back(p);
    }
    cout << (long long)ans.size() << '\n';
    for (long long i = 0; i < (long long)ans.size(); ++i)
      cout << ans[i].in << " " << ans[i].jn << " " << ans[i].x << '\n';
  }
  return 0;
}
