#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
struct ngoc {
  int i, j, val;
};
ngoc res[300005];
void nhap() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
}
void xuli() {
  int tong = 0;
  for (int i = 1; i <= n; i++) {
    tong = tong + a[i];
  }
  if (tong % n != 0) {
    cout << -1 << "\n";
    return;
  }
  int tb = tong / n;
  int dem = 0;
  for (int i = 2; i <= n; i++) {
    int tmp = i - (a[i] % i);
    if (tmp == i) tmp = 0;
    dem++;
    res[dem].i = 1;
    res[dem].j = i;
    res[dem].val = tmp;
    if (tmp == 0) dem--;
    a[1] -= tmp;
    dem++;
    res[dem].i = i;
    res[dem].j = 1;
    res[dem].val = (a[i] + tmp) / i;
    a[1] = a[1] + a[i] + tmp;
  }
  for (int i = 2; i <= n; i++) {
    dem++;
    res[dem].i = 1;
    res[dem].j = i;
    res[dem].val = tb;
  }
  cout << dem << "\n";
  for (int i = 1; i <= dem; i++) {
    cout << res[i].i << " " << res[i].j << " " << res[i].val << "\n";
  }
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    nhap();
    xuli();
  }
}
