#include <bits/stdc++.h>
using namespace std;
template <typename G1, typename G2 = G1, typename G3 = G1>
struct triple {
  G1 first;
  G2 second;
  G3 T;
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<long long> v(n);
    for (auto &i : v) cin >> i;
    int sum = 0;
    for (auto i : v) sum += i;
    if (sum % n) {
      cout << "-1\n";
      continue;
    }
    int target = sum / n;
    vector<triple<long long> > ans;
    for (int i = 1; i < n; i++) {
      int k = v[i] % (i + 1);
      if (k) k = i + 1 - k;
      if (k) ans.push_back({1, i + 1, k});
      v[0] -= k;
      v[i] += k;
      if (v[i]) ans.push_back({i + 1, 1, v[i] / (i + 1)});
      v[0] += v[i];
      v[i] = 0;
    }
    for (int i = 1; i < n; i++) ans.push_back({1, i + 1, target});
    cout << ans.size() << '\n';
    for (auto i : ans) cout << i.first << " " << i.second << " " << i.T << '\n';
  }
  return 0;
}
