#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, s = 0;
    cin >> n;
    long long a[n + 1];
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      s += a[i];
    }
    if (s % n != 0)
      cout << -1 << "\n";
    else {
      long long ans = 0;
      for (int i = 2; i <= n; i++) {
        if (a[i] % i == 0) {
          ans++;
        } else {
          ans += 2;
        }
      }
      ans += n - 1;
      cout << ans << "\n";
      for (int i = 2; i <= n; i++) {
        if (a[i] % i == 0) {
          cout << i << " " << 1 << " " << a[i] / i << endl;
          a[1] = a[1] + i * (a[i] / i);
        } else {
          cout << 1 << " " << i << " " << i - a[i] % i << "\n";
          a[1] = a[1] - (i - a[i] % i);
          a[i] = a[i] + (i - a[i] % i);
          cout << i << " " << 1 << " " << a[i] / i << endl;
          a[1] = a[1] + i * (a[i] / i);
        }
      }
      for (int i = 2; i <= n; i++) {
        cout << 1 << " " << i << " " << s / n << "\n";
      }
    }
  }
}
