#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
struct dat {
  int i, j, x;
};
int n, a[N];
vector<dat> ans;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
    if (sum % n != 0)
      cout << -1 << '\n';
    else {
      ans.clear();
      for (int i = 2; i <= n; i++) {
        if (a[i] % i == 0)
          ans.push_back((dat){i, 1, a[i] / i});
        else {
          ans.push_back((dat){1, i, i - a[i] % i});
          ans.push_back((dat){i, 1, a[i] / i + 1});
        }
      }
      for (int i = 2; i <= n; i++) ans.push_back((dat){1, i, sum / n});
      cout << int(ans.size()) << '\n';
      for (auto t : ans) cout << t.i << ' ' << t.j << ' ' << t.x << '\n';
    }
  }
  return 0;
}
