#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n + 1], sum = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    if (sum % n) {
      cout << -1 << "\n";
      continue;
    }
    int val = sum / n;
    vector<tuple<int, int, int>> ans;
    for (int i = 2; i <= n; i++) {
      int num;
      if (a[i] % i == 0)
        num = 0;
      else {
        num = ((a[i] / i) + 1) * i;
        num = num - a[i];
      }
      if (num) {
        ans.push_back({1, i, num});
        a[i] += num;
        a[1] -= num;
      }
      ans.push_back({i, 1, a[i] / i});
      a[1] += a[i], a[i] = 0;
    }
    for (int i = 2; i <= n; i++) {
      ans.push_back({1, i, val});
      a[i] = val, a[1] -= val;
    }
    cout << ans.size() << "\n";
    for (auto x : ans) {
      cout << get<0>(x) << " " << get<1>(x) << " " << get<2>(x) << "\n";
    }
  }
}
