#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << "[ " << *it << " = " << a << " ] ";
  err(++it, args...);
}
class Data {
 public:
  long long int a, b, x;
  Data(long long int aa, long long int bb, long long int xx) {
    a = aa, b = bb, x = xx;
  }
};
void test(int T) {
  long long int n, i, j, k, p, x, sum = 0;
  scanf("%lld", &(n));
  vector<long long int> v(n + 1);
  for (i = 1; i < n + 1; i++) scanf("%lld", &(v[i])), sum += v[i];
  if (sum % n != 0) {
    printf("-1\n");
    return;
  }
  vector<Data> ans;
  for (i = 2; i < n + 1; i++) {
    x = (i - (v[i] % i)) % i;
    ans.push_back(Data(1, i, x));
    v[i] += x;
    v[1] -= x;
    x = v[i] / i;
    ans.push_back(Data(i, 1, x));
    v[i] -= (x * i);
    v[1] += (x * i);
  }
  x = sum / n;
  for (i = 2; i < n + 1; i++) ans.push_back(Data(1, i, x));
  p = ans.size();
  printf("%lld\n", p);
  for (i = 0; i < p; i++) {
    printf("%lld %lld %lld\n", ans[i].a, ans[i].b, ans[i].x);
  }
}
void Test() {
  int T;
  scanf("%d\n", &T);
  for (int cs = 1; cs <= T; cs++) test(cs);
}
int main() {
  Test();
  return 0;
}
