#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int tests;
  cin >> tests;
  while (tests-- > 0) {
    int N;
    cin >> N;
    vector<int> a(N + 1);
    long long sum = 0;
    for (int i = 1; i <= N; ++i) {
      cin >> a[i];
      sum += a[i];
    }
    if (sum % N) {
      cout << "-1\n";
      continue;
    }
    int average = sum / N;
    cout << 3 * (N - 1) << "\n";
    for (int i = 2; i <= N; ++i) {
      int need = (i - a[i] % i) % i;
      cout << 1 << " " << i << " " << need << "\n";
      a[1] -= need;
      a[i] += need;
      cout << i << " " << 1 << " " << a[i] / i << "\n";
      a[1] += a[i];
    }
    for (int i = 2; i <= N; ++i)
      cout << 1 << " " << i << " " << average << "\n";
  }
  return 0;
}
