#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 7;
int a[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int sum = 0, ans = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      sum += a[i];
      if (a[i] % i) ans++;
    }
    if (sum % n != 0) {
      cout << -1 << endl;
      continue;
    }
    int avg = sum / n;
    cout << 2 * (n - 1) + ans << endl;
    for (int i = 2; i <= n; i++) {
      if (a[i] % i == 0) {
        cout << i << ' ' << 1 << ' ' << (a[i] / i) << endl;
      } else {
        cout << 1 << ' ' << i << ' ' << (i - a[i] % i) << endl;
        cout << i << ' ' << 1 << ' ' << (a[i] / i + 1) << endl;
      }
    }
    for (int i = 2; i <= n; i++) {
      cout << 1 << ' ' << i << ' ' << avg << endl;
    }
  }
  return 0;
}
