#include <bits/stdc++.h>
using namespace std;
void setIO(string str, bool dbg) {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  if (!dbg) {
    freopen((str + ".in").c_str(), "r", stdin);
    freopen((str + ".out").c_str(), "w", stdout);
  }
}
const int MAX = 5e5 + 5;
const int LEN = 1e6 + 5;
const int LVL = 2e1 + 0;
const long long int MOD = 1e9 + 7;
const long long int INF = 2e9;
int xyz = 1;
int n;
int arr[MAX];
void exc(int i, int j, int x) {
  cout << i << " " << j << " " << x << endl;
  arr[i] -= x * i;
  arr[j] += x * i;
}
void run() {
  cin >> n;
  long long int sum = 0;
  for (int i = 1; i <= n; i++) cin >> arr[i], sum += arr[i];
  if (sum % n) {
    cout << "-1\n";
    return;
  }
  cout << 3 * (n - 1) << endl;
  for (int i = 2; i <= n; i++) {
    int transfer = ceil((double)arr[i] / i) * i - arr[i];
    exc(1, i, transfer);
    exc(i, 1, arr[i] / i);
  }
  for (int i = 2; i <= n; i++) exc(1, i, sum / n);
}
int main() {
  setIO("", 1);
  cin >> xyz;
  while (xyz--) run();
  return 0;
}
