#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
  cout << "[";
  for (auto& i : v) cout << i << ", ";
  cout << "]" << '\n';
  return os;
}
template <class T>
ostream& operator<<(ostream& os, set<T> v) {
  cout << "[";
  for (auto& i : v) cout << i << ", ";
  cout << "]" << '\n';
  return os;
}
template <typename K, typename V>
ostream& operator<<(ostream& os, pair<K, V> p) {
  os << "{" << p.first + 1 << ", " << p.second + 1 << "} ";
  return os;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    int ar[n + 1];
    int su = 0;
    for (int i = 1; i <= n; i++) {
      cin >> ar[i];
      su += ar[i];
    }
    if (su % n) {
      cout << -1 << '\n';
      continue;
    }
    vector<pair<int, pair<int, int>>> ans;
    for (int i = 2; i <= n; i++) {
      if ((ar[i] % i) != 0) {
        int temp = i - (ar[i] % i);
        ans.push_back({1, {i, temp}});
        ar[i] += temp;
        ar[1] -= temp;
      }
      ans.push_back({i, {1, ar[i] / i}});
      ar[1] += ar[i];
      ar[i] = 0;
    }
    for (int i = 2; i <= n; i++) {
      ans.push_back({1, {i, su / n}});
    }
    cout << ans.size() << '\n';
    for (auto i : ans) {
      cout << i.first << " " << i.second.first << " " << i.second.second
           << '\n';
    }
  }
}
