#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n + 1];
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    if (sum % n != 0)
      cout << -1 << endl;
    else {
      vector<tuple<int, int, int>> ans;
      int avg = sum / n;
      for (int i = 2; i <= n; i++) {
        int p = a[i];
        a[i] %= i;
        if (a[i] > 0) {
          ans.push_back({1, i, i - a[i]});
          p += (i - a[i]);
        }
        ans.push_back({i, 1, p / i});
        a[i] = 0;
      }
      a[1] = sum;
      for (int i = 2; i <= n; i++) {
        int x = avg - a[i];
        if (x > 0) {
          ans.push_back({1, i, x});
          a[1] -= x;
        }
      }
      cout << ans.size() << endl;
      for (auto aa : ans) {
        cout << get<0>(aa) << " " << get<1>(aa) << " " << get<2>(aa) << endl;
      }
    }
  }
  return 0;
}
