#include <bits/stdc++.h>
using namespace std;
const long double eps = 0.0000000001;
const int MOD = 998244353;
const int INF = 1000055555;
const long long LLINF = 1223372000000000555;
const int N = 2255555;
const int M = 2222;
struct query {
  int i;
  int j;
  int x;
};
int a[N];
vector<query> v;
void make(int i, int j, int x) {
  v.push_back({i, j, x});
  a[i] -= x * i;
  a[j] += x * i;
}
void solve() {
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum % n != 0) {
    cout << -1 << endl;
    return;
  }
  int val = sum / n;
  v.clear();
  for (int i = 2; i <= n; i++) {
    if (a[i] % i == 0) {
      make(i, 1, a[i] / i);
    } else {
      make(1, i, i - a[i] % i);
      make(i, 1, a[i] / i);
    }
  }
  for (int i = 2; i <= n; i++) {
    make(1, i, val);
  }
  cout << v.size() << endl;
  for (auto q : v) {
    cout << q.i << ' ' << q.j << ' ' << q.x << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
