#include <bits/stdc++.h>
using namespace std;
void test_case();
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) test_case();
  return 0;
}
int N, a[11234];
struct tp {
  int a, b, x;
  void p() {
    cout << a << " " << b << " " << x << "\n";
    return;
  }
};
vector<tp> V;
void test_case() {
  cin >> N;
  V.clear();
  int sum = 0;
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum % N != 0) {
    cout << "-1\n";
    return;
  }
  sum /= N;
  for (int i = 2; i <= N; i++) {
    if (a[i] % i != 0) {
      int A = 1, B = i, X = i - (a[i] % i);
      V.push_back({A, B, X});
      a[A] -= X, a[B] += X;
    }
    if (a[i] / i != 0) {
      int A = i, B = 1, X = a[i] / i;
      V.push_back({i, 1, a[i] / i});
      a[A] -= X * A, a[B] += X * A;
    }
  }
  for (int i = 2; i <= N; i++) {
    V.push_back({1, i, sum});
  }
  cout << V.size() << "\n";
  for (auto i : V) i.p();
  return;
}
