#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int T;
  cin >> T;
  while (T--) {
    long long int n;
    cin >> n;
    vector<long long int> arr(n);
    for (long long int i = 0; i < n; i++) cin >> arr[i];
    long long int tot = 0;
    for (long long int i = 0; i < n; i++) tot += arr[i];
    if (tot % n != 0) {
      cout << -1 << "\n";
      continue;
    }
    long long int target = tot / n;
    vector<vector<long long int> > ans;
    for (long long int i = 1; i < n; i++) {
      vector<long long int> new_ans(3);
      new_ans[0] = 0;
      new_ans[1] = i;
      new_ans[2] = (i + 1 - (arr[i]) % (i + 1)) % (i + 1);
      arr[new_ans[0]] -= (new_ans[0] + 1) * new_ans[2];
      arr[new_ans[1]] += (new_ans[0] + 1) * new_ans[2];
      ans.push_back(new_ans);
      new_ans[0] = i;
      new_ans[1] = 0;
      new_ans[2] = arr[i] / (i + 1);
      arr[new_ans[0]] -= (new_ans[0] + 1) * new_ans[2];
      arr[new_ans[1]] += (new_ans[0] + 1) * new_ans[2];
      ans.push_back(new_ans);
    }
    for (long long int i = 1; i < n; i++) {
      vector<long long int> new_ans(3);
      new_ans[0] = 0;
      new_ans[1] = i;
      new_ans[2] = target - arr[i];
      arr[new_ans[0]] -= (new_ans[0] + 1) * new_ans[2];
      arr[new_ans[1]] += (new_ans[0] + 1) * new_ans[2];
      ans.push_back(new_ans);
    }
    cout << (long long int)ans.size() << "\n";
    for (long long int i = 0; i < (long long int)ans.size(); i++)
      cout << ans[i][0] + 1 << " " << ans[i][1] + 1 << " " << ans[i][2] << "\n";
  }
}
