#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
const int N = 2e5 + 10;
int t, n, a[N];
int main() {
  ios::sync_with_stdio(false);
  for (cin >> t; t; t--) {
    cin >> n;
    int s = 0;
    for (int i = 1; i <= n; i++) cin >> a[i], s += a[i];
    if (s % n)
      cout << -1 << '\n';
    else {
      vector<array<int, 3> > v;
      for (int i = 2; i <= n; i++) {
        if (a[i] % i == 0) {
          v.push_back({i, 1, a[i] / i});
          a[1] += a[i];
          a[i] = 0;
        } else {
          v.push_back({1, i, i - a[i] % i});
          v.push_back({i, 1, (a[i] + i - 1) / i});
          a[1] += a[i];
          a[i] = 0;
        }
      }
      for (int i = 2; i <= n; i++) {
        v.push_back({1, i, s / n});
      }
      cout << v.size() << '\n';
      for (auto k : v) cout << k[0] << ' ' << k[1] << ' ' << k[2] << '\n';
    }
  }
  return 0;
}
