#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
void query(long long i, long long j, long long first) {
  cout << i + 1 << " " << j + 1 << " " << first / (i + 1) << "\n";
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long sum = 0;
  for (auto &el : a) {
    cin >> el;
    sum += el;
  }
  if (sum % n) {
    cout << -1 << '\n';
    return;
  }
  long long first = sum / n;
  vector<pair<pair<long long, long long>, long long>> ans;
  cout << (n - 1) * 3 << '\n';
  for (long long i = 1; i < n; i++) {
    long long cnt = (i + 1) - (a[i] % (i + 1) == 0 ? (i + 1) : a[i] % (i + 1));
    query(0, i, cnt);
    a[0] -= cnt;
    a[i] += cnt;
    query(i, 0, a[i]);
    a[0] += a[i];
    a[i] = 0;
  }
  for (long long i = n - 1; i > 0; i--) {
    query(0, i, first);
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
