#include <bits/stdc++.h>
using namespace std;
int d[1000001];
int n;
int ans[10000001][3];
int cnt = 0;
void add(int a, int b, int c) {
  ans[++cnt][0] = a;
  ans[cnt][1] = b;
  ans[cnt][2] = c;
  d[a] -= a * c;
  d[b] += a * c;
}
int t;
void dealA(int pos) {
  int num = d[pos];
  if (num == 0) return;
  int x = num / pos;
  if (num % pos != 0) x++;
  int addon = x * pos - num;
  if (d[1] < addon) return;
  if (x != 0) add(1, pos, addon);
  add(pos, 1, x);
}
void dealC(int pos) {
  int num = d[pos];
  if (num < t) {
    add(1, pos, t - num);
  }
}
void solve() {
  cnt = 0;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += d[i];
  }
  if (sum % n != 0) {
    cout << -1 << endl;
    return;
  }
  t = sum / n;
  for (int t = 1; t <= 20; t++) {
    for (int i = n; i >= 2; i--) dealA(i);
  }
  for (int i = 2; i <= n; i++) dealC(i);
  cout << cnt << endl;
  for (int i = 1; i <= cnt; i++) {
    cout << ans[i][0] << ' ' << ans[i][1] << ' ' << ans[i][2] << endl;
  }
}
int D[10000001];
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> d[i];
      D[i] = d[i];
    }
    solve();
  }
}
