#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void umin(T& x, const U& y) {
  x = min(x, (T)y);
}
template <class T, class U>
void umax(T& x, const U& y) {
  x = max(x, (T)y);
}
template <class T, class U>
void init(vector<T>& v, U x, size_t n) {
  v = vector<T>(n, (T)x);
}
template <class T, class U, typename... W>
void init(vector<T>& v, U x, size_t n, W... m) {
  v = vector<T>(n);
  for (auto& a : v) init(a, x, m...);
}
int main(int argc, char** argv) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(15);
  if (argc == 2 && atoi(argv[1]) == 123456789)
    freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
  int T = 1;
  cin >> T;
  for (int tt = 1; tt <= T; tt++) {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    long long s = 0;
    for (int i = 1; i <= n; i++) s += a[i];
    if (s % n) {
      cout << -1 << endl;
      continue;
    }
    int t = s / n;
    vector<vector<int>> ops;
    for (int i = 2; i <= n; i++) {
      if (a[i] % i) {
        int x = i - a[i] % i;
        a[1] -= x;
        a[i] += x;
        ops.push_back({1, i, x});
      }
      int x = a[i] / i;
      a[i] -= x * i;
      a[1] += x * i;
      ops.push_back({i, 1, x});
    }
    for (int i = 2; i <= n; i++) {
      int x = t - a[i];
      a[1] -= x;
      a[i] += x;
      ops.push_back({1, i, x});
    }
    for (int i = 1; i <= n; i++) assert(a[i] == t);
    cout << ops.size() << endl;
    for (auto it : ops) {
      for (auto it2 : it) cout << it2 << " ";
      cout << endl;
    }
  }
  if (argc == 2 && atoi(argv[1]) == 123456789)
    cout << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
  return 0;
}
