#include <bits/stdc++.h>
constexpr long long MOD = 1000000007;
using namespace std;
void io() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void update(vector<tuple<int, int, long long>> &sol, vector<long long> &ar,
            int i, int j, int x) {
  sol.push_back({i, j, x});
  ar[i] -= 1LL * x * i;
  ar[j] += 1LL * x * i;
}
vector<tuple<int, int, long long>> solve(vector<long long> &ar, int n,
                                         long long sum) {
  vector<tuple<int, int, long long>> sol;
  for (int i = 2; i <= n; i++) {
    if (ar[i] % i) {
      update(sol, ar, 1, i, i - (ar[i] % i));
    }
    update(sol, ar, i, 1, ar[i] / i);
  }
  long long target = sum / n;
  for (int i = 2; i <= n; i++) {
    update(sol, ar, 1, i, target);
  }
  return sol;
}
int main() {
  io();
  int n, m, x, y, t;
  long long sum = 0;
  cin >> t;
  while (t--) {
    cin >> n;
    sum = 0;
    vector<long long> ar(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> ar[i];
      sum += 1LL * ar[i];
    }
    if (sum % n != 0) {
      cout << "-1\n";
    } else {
      vector<tuple<int, int, long long>> sol = solve(ar, n, sum);
      cout << sol.size() << "\n";
      for (auto [x, y, z] : sol) {
        cout << x << " " << y << " " << z << "\n";
      }
    }
  }
  return 0;
}
