#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  long long t, k, n, m, d, u, v;
  t = 1;
  cin >> t;
  while (t--) {
    cin >> n;
    long long sum = 0;
    vector<long long> val(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> val[i];
      sum += val[i];
    }
    if (sum % n) {
      cout << -1 << "\n";
    } else {
      long long avg = sum / n;
      vector<long long> ans;
      for (int i = 2; i <= n; i++) {
        if (val[i] % i) {
          ans.push_back(1);
          ans.push_back(i);
          u = i - val[i] % i;
          ans.push_back(u);
          val[i] += u;
        }
        ans.push_back(i);
        ans.push_back(1);
        ans.push_back(val[i] / i);
      }
      for (int i = 2; i <= n; i++) {
        ans.push_back(1);
        ans.push_back(i);
        ans.push_back(avg);
      }
      cout << ans.size() / 3 << "\n";
      for (int i = 0; i < ans.size(); i += 3) {
        cout << ans[i] << " " << ans[i + 1] << " " << ans[i + 2] << "\n";
      }
    }
  }
  return 0;
}
