#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  for (long long int i = 0; i < t; i++) {
    long long int n;
    cin >> n;
    long long int arr[n];
    long long int sum = 0;
    for (long long int i = 0; i < n; i++) {
      cin >> arr[i];
      sum += arr[i];
    }
    if (sum % n != 0) {
      cout << -1 << endl;
    } else {
      long long int final = sum / n;
      cout << 3 * (n - 1) << endl;
      for (long long int i = 1; i < n; i++) {
        if (arr[i] % (i + 1) == 0) {
          cout << 1 << " " << i + 1 << " " << 0 << endl;
        } else {
          cout << 1 << " " << i + 1 << " " << (i + 1) - arr[i] % (i + 1)
               << endl;
          arr[i] += (i + 1) - arr[i] % (i + 1);
          arr[0] -= (i + 1) - arr[i] % (i + 1);
        }
        cout << i + 1 << " " << 1 << " " << arr[i] / (i + 1) << endl;
        arr[0] += arr[i];
        arr[i] = 0;
      }
      for (long long int i = 1; i < n; i++) {
        cout << 1 << " " << i + 1 << " " << final << endl;
      }
    }
  }
  return 0;
}
