#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
long long a[maxn];
long long n, sum;
struct node {
  int i, j;
  long long x;
} ans[maxn * 4];
int tot;
void solve() {
  sum = 0;
  tot = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum % n) {
    cout << "-1\n";
    return;
  }
  long long aver = sum / n;
  for (int i = 2; i <= n; ++i) {
    if (a[i] % i == 0) {
      ans[++tot] = node{i, 1, a[i] / i};
      a[1] += a[i];
      a[i] = 0;
    } else {
      int temp = a[i] % i;
      ans[++tot] = {1, i, i - temp};
      a[i] += i - temp;
      a[1] -= i - temp;
      ans[++tot] = node{i, 1, a[i] / i};
      a[1] += a[i];
      a[i] = 0;
    }
  }
  for (int i = 2; i <= n; ++i) {
    ans[++tot] = node{1, i, aver};
  }
  cout << tot << "\n";
  for (int i = 1; i <= tot; ++i) {
    cout << ans[i].i << " " << ans[i].j << " " << ans[i].x << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  int Case;
  cin >> Case;
  while (Case--) {
    solve();
  }
  return 0;
}
