#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      sum += a[i];
    }
    if (sum % n) {
      cout << -1 << "\n";
      continue;
    }
    long long aa = sum / n;
    vector<vector<int>> ans;
    auto Update = [&](int i, int j, int x) {
      a[i] -= i * x;
      a[j] += i * x;
      ans.push_back({i, j, x});
    };
    for (int i = 2; i <= n; ++i) {
      if (a[i] % i) {
        Update(1, i, i - (a[i] % i));
      }
      Update(i, 1, a[i] / i);
    }
    for (int i = 2; i <= n; ++i) {
      Update(1, i, aa);
    }
    cout << ans.size() << "\n";
    for (auto el : ans) {
      for (auto x : el) {
        cout << x << " ";
      }
      cout << "\n";
    }
  }
  return 0;
}
