#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int Case, n;
int a[N];
int main() {
  scanf("%d", &Case);
  while (Case--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
      scanf("%d", a + i);
    }
    vector<vector<int> > ans;
    for (int i = 2; i <= n; ++i) {
      if (a[i] % i) {
        int nd = i - a[i] % i;
        ans.push_back({1, i, nd});
        a[1] -= nd;
        a[i] += nd;
      }
      int nd = a[i] / i;
      ans.push_back({i, 1, nd});
      a[1] += nd * i;
      a[i] -= nd * i;
    }
    if (a[1] % n) {
      puts("-1");
      continue;
    }
    int nd = a[1] / n;
    for (int i = 2; i <= n; ++i) ans.push_back({1, i, nd});
    printf("%d\n", (int)ans.size());
    for (auto x : ans) printf("%d %d %d\n", x[0], x[1], x[2]);
  }
  return 0;
}
