#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int t, n, x[N], y[N];
long long a[N], val[N];
int main() {
  cin >> t;
  while (t--) {
    scanf("%d", &n);
    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%lld", a + i);
      sum += a[i];
    }
    if (sum % n) {
      puts("-1");
      continue;
    }
    sum /= n;
    int m = 0;
    for (int i = 2; i <= n; ++i) {
      long long req = a[i] % i;
      if (req) {
        req = i - req, ++m;
        x[m] = 1, y[m] = i, val[m] = req;
        a[1] -= req, a[i] += req;
      }
      ++m;
      x[m] = i, y[m] = 1, val[m] = a[i] / i;
      a[1] += a[i], a[i] = 0;
    }
    for (int i = 2; i <= n; ++i) {
      ++m;
      x[m] = 1, y[m] = i, val[m] = sum;
      a[1] -= sum, a[i] += sum;
    }
    printf("%d\n", m);
    for (int i = 1; i <= m; ++i) printf("%d %d %lld\n", x[i], y[i], val[i]);
  }
  return 0;
}
