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