#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1E4 + 1;
int arr[MAXN], ii[3 * MAXN], jj[3 * MAXN], xx[3 * MAXN];
void rec(int i, int j, int x, int &c) {
  ii[c] = i;
  jj[c] = j;
  xx[c] = x;
  arr[i] -= i * x;
  arr[j] += i * x;
  c++;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> arr[i];
    }
    int sum = 0, avg;
    for (int i = 1; i <= n; i++) {
      sum += arr[i];
    }
    if (sum % n > 0) {
      cout << "-1\n";
      continue;
    }
    avg = sum / n;
    int cnt = 0;
    for (int i = 2; i <= n; i++) {
      if (arr[i] % i > 0) rec(1, i, i - (arr[i] % i), cnt);
      rec(i, 1, arr[i] / i, cnt);
    }
    for (int i = 2; i <= n; i++) {
      rec(1, i, avg, cnt);
    }
    cout << cnt << "\n";
    for (int i = 0; i < cnt; i++) {
      cout << ii[i] << " " << jj[i] << " " << xx[i] << "\n";
    }
  }
  return 0;
}
