#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n + 1];
    for (long long i = 1; i <= n; i++) cin >> a[i];
    long long sum = 0;
    for (long long i = 1; i <= n; i++) sum += a[i];
    if (sum % n != 0) {
      cout << -1 << "\n";
    } else {
      vector<vector<long long>> ans;
      sum = sum / n;
      for (long long i = 2; i <= n; i++) {
        if (a[i] % i == 0) {
          ans.push_back({i, 1, a[i] / i});
          a[1] += (a[i]);
        } else {
          long long val = (i - a[i] % i);
          ans.push_back({1, i, val});
          a[i] += val;
          ans.push_back({i, 1, a[i] / i});
        }
      }
      for (long long i = 2; i <= n; i++) {
        ans.push_back({1, i, sum});
      }
      cout << ans.size() << "\n";
      for (auto c : ans) {
        cout << c[0] << " " << c[1] << " " << c[2] << "\n";
      }
    }
  }
  return 0;
}
