#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  for (int t = (0); t < (T); ++t) {
    int n;
    cin >> n;
    vector<int> a(n);
    int summ = 0;
    for (int i = (0); i < (n); ++i) {
      cin >> a[i];
      summ += a[i];
    }
    if (summ % n != 0) {
      cout << -1 << endl;
      continue;
    }
    vector<int> is, js, xs;
    for (int i = (1); i < (n); ++i) {
      if (a[i] % (i + 1) == 0) {
        is.push_back(i + 1);
        js.push_back(1);
        xs.push_back(a[i] / (i + 1));
        a[0] += a[i];
        a[i] = 0;
      } else {
        int tmp = i + 1 - (a[i] % (i + 1));
        a[i] += tmp;
        a[0] -= tmp;
        is.push_back(1);
        js.push_back(i + 1);
        xs.push_back(tmp);
        is.push_back(i + 1);
        js.push_back(1);
        xs.push_back(a[i] / (i + 1));
        a[0] += a[i];
        a[i] = 0;
      }
    }
    int target = summ / n;
    for (int i = (1); i < (n); ++i) {
      is.push_back(1);
      js.push_back(i + 1);
      xs.push_back(target);
    }
    cout << int((is).size()) << endl;
    for (int i = (0); i < (int((is).size())); ++i) {
      cout << is[i] << " " << js[i] << " " << xs[i] << endl;
    }
  }
}
