#include <bits/stdc++.h>
int main() {
  int cas;
  scanf("%d", &cas);
  while (cas--) {
    int n;
    scanf("%d", &n);
    std::vector<int> a(n + 1);
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
      sum += a[i];
    }
    if (sum % n) {
      puts("-1");
      continue;
    }
    int avg = sum / n;
    std::vector<std::tuple<int, int, int>> ops;
    std::set<std::pair<int, int>> f, g;
    for (int i = 2; i <= n; ++i) {
      if (a[i] - a[i] % i) {
        f.emplace(a[i] - a[i] % i, i);
      }
      if (a[i] % i) {
        g.emplace(i - a[i] % i, i);
      }
    }
    while (!g.empty()) {
      while (a[1] < g.begin()->first && !f.empty()) {
        auto it = std::prev(f.end());
        a[1] += it->first;
        a[it->second] %= it->second;
        ops.emplace_back(it->second, 1, it->first / it->second);
        f.erase(it);
      }
      if (a[1] < g.begin()->first) break;
      auto it = g.begin();
      f.erase(std::make_pair(a[it->second] - a[it->second] % it->second,
                             it->second));
      ops.emplace_back(1, it->second, it->first);
      a[it->second] += it->first;
      a[1] -= it->first;
      ops.emplace_back(it->second, 1, a[it->second] / it->second);
      a[1] += a[it->second];
      a[it->second] = 0;
      g.erase(it);
    }
    while (!f.empty()) {
      auto it = std::prev(f.end());
      a[1] += it->first;
      a[it->second] %= it->second;
      ops.emplace_back(it->second, 1, it->first / it->second);
      f.erase(it);
    }
    bool flag = true;
    for (int i = 2; i <= n; ++i) {
      if (a[i] > avg) {
        flag = false;
      }
    }
    if (!flag) {
      puts("-1");
      continue;
    }
    for (int i = 2; i <= n; ++i) {
      if (a[i] < avg) {
        ops.emplace_back(1, i, avg - a[i]);
      }
    }
    printf("%d\n", ops.size());
    for (const auto& t : ops) {
      int i, j, x;
      std::tie(i, j, x) = t;
      printf("%d %d %d\n", i, j, x);
    }
  }
}
