#include <bits/stdc++.h>
using namespace std;
int t, n, sum, a[10005];
vector<pair<int, pair<int, int>>> ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    sum = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    if (sum % n != 0) {
      cout << "-1\n";
      continue;
    }
    int x = sum / n;
    ans.clear();
    for (int i = 2; i <= n; i++) {
      if (a[i] % i != 0) {
        int need = (i - (a[i] % i)) % i;
        ans.push_back({1, {i, need}});
        a[1] -= need;
        a[i] += need;
      }
      if (a[i] / i > 0) {
        int res = a[i] / i;
        ans.push_back({i, {1, res}});
        a[i] -= i * res;
        a[1] += i * res;
      }
    }
    for (int i = 2; i <= n; i++) {
      int need = x - a[i];
      ans.push_back({1, {i, need}});
      a[1] -= need;
      a[i] += need;
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i].first << " " << ans[i].second.first << " "
           << ans[i].second.second << '\n';
    }
  }
  return 0;
}
