#include <bits/stdc++.h>
using namespace std;
int a[10005], sum = 0;
int x[3 * 10005], y[3 * 10005], add[3 * 10005], tmp;
int main() {
  int t, n, k;
  cin >> t;
  while (t--) {
    cin >> n;
    sum = 0;
    for (int i = int(0); i < int(n); i++) scanf("%d", a + i), sum += a[i];
    if (sum % n) {
      cout << -1 << endl;
      continue;
    }
    sum /= n;
    k = 0;
    for (int i = int(1); i < int(n); i++) {
      tmp = a[i] / (i + 1);
      if (tmp * (i + 1) != a[i]) {
        x[k] = 1, y[k] = i + 1, add[k++] = (i + 1) - a[i] % (i + 1);
        x[k] = i + 1, y[k] = 1, add[k++] = tmp + 1;
      } else
        x[k] = i + 1, y[k] = 1, add[k++] = tmp;
    }
    for (int i = int(1); i < int(n); i++)
      x[k] = 1, y[k] = i + 1, add[k++] = sum;
    cout << k << endl;
    for (int i = int(0); i < int(k); i++)
      printf("%d %d %d\n", x[i], y[i], add[i]);
  }
}
