#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e4 + 9;
long long a[maxn];
long long n;
void solve() {
  cin >> n;
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum % n != 0) {
    cout << "-1\n";
    return;
  }
  sum /= n;
  long long j = -1;
  for (long long i = n - 1; i >= 1; i--) {
    if (a[i] >= i + 1) {
      j = i;
      break;
    }
  }
  vector<pair<pair<long long, long long>, long long> > ans;
  if (j != -1) {
    ans.emplace_back(make_pair(j, 0), 1);
    a[j] -= j + 1;
    a[0] += j + 1;
    for (long long e = j; e >= 1; e--) {
      if (a[e] % (e + 1) != 0) {
        long long x = (e + 1) - a[e] % (e + 1);
        ans.emplace_back(make_pair(0, e), x);
        a[0] -= x;
        a[e] += x;
      }
      ans.emplace_back(make_pair(e, 0), a[e] / (e + 1));
      a[0] += a[e];
      a[e] = 0;
    }
  } else {
    j = 0;
  }
  vector<pair<long long, long long> > kek;
  for (long long e = j + 1; e < n; e++) {
    kek.emplace_back((e + 1) - a[e], e);
  }
  sort(kek.begin(), kek.end());
  for (auto x : kek) {
    if (a[0] >= x.first) {
      ans.emplace_back(make_pair(0, x.second), x.first);
      ans.emplace_back(make_pair(x.second, 0), 1);
      a[0] += a[x.second];
      a[x.second] = 0;
    } else {
      cout << "-1\n";
      return;
    }
  }
  for (long long i = 1; i < n; i++) {
    ans.emplace_back(make_pair(0, i), sum);
  }
  if ((long long)ans.size() > 3 * n) {
    cout << "-1\n";
    return;
  }
  cout << ans.size() << "\n";
  for (auto x : ans)
    cout << x.first.first + 1 << " " << x.first.second + 1 << " " << x.second
         << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
}
