#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#ifdef DEBUG
#define endl endl
#else
#define endl "\n"
#endif

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())
#define UNIQUE(v) \
    SORT(v);      \
    v.resize(distance(v.begin(), unique(v.begin(), v.end())))

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << endl;
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF DBL_MAX
// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    vector<vll> res;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
    }

    ll sm = accumulate(a.begin(), a.end(), 0);
    if (sm % n != 0) {
        cout << -1 << endl;
        return;
    }

    ll goal = sm / n;

    FOR(i, 1, n) {
        if (a[i] >= i + 1) {
            ll x = a[i] / (i + 1);
            if (x == 0)
                continue;
            res.push_back({i + 1, 1, x});
            ll reduced = x * (i + 1);
            a[i] -= reduced;
            a[0] += reduced;
        }
    }

    vector<pll> leftIdx;
    FOR(i, 1, n) {
        if (a[i] > goal) {
            assert(i + 1 > a[i]);
            ll left = i + 1 - a[i];
            leftIdx.push_back({left, i});
        }
    }
    SORT(leftIdx);
    for (auto& pr : leftIdx) {
        ll left = pr.first;
        ll i = pr.second;
        res.push_back({1, i + 1, left});
        a[0] -= left;
        assert(a[0] >= 0);
        a[i] += left;
        res.push_back({i + 1, 1, 1});
        a[0] += a[i];
        a[i] = 0;
    }

    FOR(i, 1, n) {
        assert(a[i] <= goal);
        ll extra = goal - a[i];
        if (extra == 0)
            continue;
        res.push_back({1, i + 1, extra});
        a[0] -= extra;
        a[i] += extra;
    }

    REP(i, n) {
        assert(a[i] == goal);
    }

    cout << res.size() << endl;
    REP(i, res.size()) {
        join(res[i], " ");
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    cin >> tt;

#ifdef DEBUG
    // for (int t = 1; t <= tt || cin.rdbuf()->in_avail(); t++) {
    //     // cout << "Case #" << t << ": ";
    //     solve();
    // }

    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
#else
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#ifdef DEBUG
#define endl endl
#else
#define endl "\n"
#endif

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())
#define UNIQUE(v) \
    SORT(v);      \
    v.resize(distance(v.begin(), unique(v.begin(), v.end())))

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << endl;
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF DBL_MAX
// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    vector<vll> res;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
    }

    ll sm = accumulate(a.begin(), a.end(), 0);
    if (sm % n != 0) {
        cout << -1 << endl;
        return;
    }

    ll goal = sm / n;

    FOR(i, 1, n) {
        if (a[i] > goal) {
            ll x = a[i] / (i + 1);
            if (x == 0)
                continue;
            res.push_back({i + 1, 1, x});
            ll reduced = x * (i + 1);
            a[i] -= reduced;
            a[0] += reduced;
        }
    }

    FOR(i, 1, n) {
        if (a[i] > goal) {
            assert(i + 1 > a[i]);
            ll left = i + 1 - a[i];
            res.push_back({1, i + 1, left});
            a[0] -= left;
            a[i] += left;
            res.push_back({i + 1, 1, 1});
            a[0] += a[i];
            a[i] = 0;
        }
    }

    FOR(i, 1, n) {
        assert(a[i] <= goal);
        ll extra = goal - a[i];
        if (extra == 0)
            continue;
        res.push_back({1, i + 1, extra});
        a[0] -= extra;
        a[i] += extra;
    }

    REP(i, n) {
        assert(a[i] == goal);
    }

    cout << res.size() << endl;
    REP(i, res.size()) {
        join(res[i], " ");
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    cin >> tt;

#ifdef DEBUG
    // for (int t = 1; t <= tt || cin.rdbuf()->in_avail(); t++) {
    //     // cout << "Case #" << t << ": ";
    //     solve();
    // }

    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
#else
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#ifdef DEBUG
#define endl endl
#else
#define endl "\n"
#endif

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())
#define UNIQUE(v) \
    SORT(v);      \
    v.resize(distance(v.begin(), unique(v.begin(), v.end())))

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << endl;
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF DBL_MAX
// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    vector<vll> res;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
    }

    ll sm = accumulate(a.begin(), a.end(), 0);
    if (sm % n != 0) {
        cout << -1 << endl;
        return;
    }

    ll goal = sm / n;

    FOR(i, 1, n) {
        ll rem = a[i] % (i + 1);
        ll need = (i + 1 - rem) % (i + 1);
        res.push_back({1, i + 1, need});
        res.push_back({i + 1, 1, a[i] / (i + 1)});
        a[0] += a[i];
        a[i] = 0;
    }

    FOR(i, 1, n) {
        res.push_back({1, i + 1, goal});
    }

    cout << res.size() << endl;
    REP(i, res.size()) {
        join(res[i], " ");
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    cin >> tt;

#ifdef DEBUG
    // for (int t = 1; t <= tt || cin.rdbuf()->in_avail(); t++) {
    //     // cout << "Case #" << t << ": ";
    //     solve();
    // }

    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
#else
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#ifdef DEBUG
#define endl endl
#else
#define endl "\n"
#endif

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())
#define UNIQUE(v) \
    SORT(v);      \
    v.resize(distance(v.begin(), unique(v.begin(), v.end())))

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << endl;
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF DBL_MAX
// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    vector<vll> res;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
    }

    ll sm = accumulate(a.begin(), a.end(), 0);
    if (sm % n != 0) {
        cout << -1 << endl;
        return;
    }

    ll goal = sm / n;

    FOR(i, 1, n) {
        if (a[i] >= i + 1) {
            ll x = a[i] / (i + 1);
            if (x == 0)
                continue;
            res.push_back({i + 1, 1, x});
            ll reduced = x * (i + 1);
            a[i] -= reduced;
            a[0] += reduced;
        }
    }

    vector<pll> leftIdx;
    FOR(i, 1, n) {
        if (a[i] > goal) {
            ll left = i + 1 - a[i];
            leftIdx.push_back({left, i});
        }
    }
    SORT(leftIdx);

    for (auto& pr : leftIdx) {
        ll left = pr.first;
        ll i = pr.second;
        res.push_back({1, i + 1, left});
        a[0] -= left;
        assert(a[0] >= 0);
        a[i] += left;
        res.push_back({i + 1, 1, 1});
        a[0] += a[i];
        a[i] = 0;
    }

    FOR(i, 1, n) {
        assert(a[i] <= goal);
        ll extra = goal - a[i];
        if (extra == 0)
            continue;
        res.push_back({1, i + 1, extra});
        a[0] -= extra;
        a[i] += extra;
    }

    REP(i, n) {
        assert(a[i] == goal);
    }

    cout << res.size() << endl;
    REP(i, res.size()) {
        join(res[i], " ");
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    cin >> tt;

#ifdef DEBUG
    // for (int t = 1; t <= tt || cin.rdbuf()->in_avail(); t++) {
    //     // cout << "Case #" << t << ": ";
    //     solve();
    // }

    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
#else
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
#endif

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

const LL mod = 998244353;

int n, a[N], tot;

struct note {

    int i, j, x;

}ans[N];

void solve() {

    scanf("%d", &n);

    LL s = 0LL;

    rep(i, 1, n) scanf("%d", &a[i]), s += a[i];

    if(s % n != 0) {

        puts("-1"); return ;

    }

    LL up = s / n; /// 最终都等于 up

    tot = 0;

    rep(i, 2, n) {

        if(a[i] > up) {

            int tmp = (a[i] - up + (i - 1)) / i;

            if(tmp * i > a[i]) {

                puts("-1"); return ;

            }

            ans[++tot] = {i, 1, tmp};

        }

    }

    rep(i, 2, n) {

        if(a[i] < up) {

            ans[++tot] = {1, i, up - a[i]};

        }

    }

    printf("%d\n", tot);

    rep(i, 1, tot) printf("%d %d %d\n", ans[i].i, ans[i].j, ans[i].x);

}

int main() {

    int _; scanf("%d", &_);
    while(_--) solve();

//    solve();

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

const LL mod = 998244353;

int n, a[N], tot;

struct note {

    int i, j, x;

}ans[N];

void solve() {

    scanf("%d", &n);

    int s = 0;

    rep(i, 1, n) scanf("%d", &a[i]), s += a[i];

    if(s % n != 0) {

        puts("-1");

        return ;

    }

    int up = s / n; /// 最终都等于 up

    tot = 0;

    rep(i, 2, n) {

        int x = a[i] / i;

        a[i] %= i;

        if(x == 0) continue;

        ans[++tot] = {i, 1, x};

    }

    rep(i, 2, n) {

        if(a[i] > up) {

            int need = i - a[i];

            if(a[1] < need) {

                puts("-1"); return ;

            }

            ans[++tot] = {1, i, need};

            a[1] -= need;

            a[i] = 0;

        }

    }

    rep(i, 2, n) {

        if(a[i] < up) {

            ans[++tot] = {1, i, up - a[i]};

        }

    }

    printf("%d\n", tot);

    rep(i, 1, tot) printf("%d %d %d\n", ans[i].i, ans[i].j, ans[i].x);

}

int main() {

    int _; scanf("%d", &_);
    while(_--) solve();

//    solve();

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

const LL mod = 998244353;

int n, a[N], tot;

struct note {

    int i, j, x;

}ans[N];

void solve() {

    scanf("%d", &n);

    LL s = 0LL;

    rep(i, 1, n) scanf("%d", &a[i]), s += a[i];

    if(s % n != 0) {

        puts("-1"); return ;

    }

    LL up = s / n; /// 最终都等于 up

    tot = 0;

    rep(i, 2, n) {

        if(a[i] > up) {

            int tmp = (a[i] - up + (i - 1)) / i;

            if(tmp * i > a[i]) {

                puts("-1"); return ;

            }

            ans[++tot] = {i, 1, tmp};

            a[i] -= tmp * i;

        }

    }

    rep(i, 2, n) {

        if(a[i] < up) {

            ans[++tot] = {1, i, up - a[i]};

        }

    }

    printf("%d\n", tot);

    rep(i, 1, tot) printf("%d %d %d\n", ans[i].i, ans[i].j, ans[i].x);

}

int main() {

    int _; scanf("%d", &_);
    while(_--) solve();

//    solve();

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

const LL mod = 998244353;

LL n, tot;

LL a[N];

struct note {

    LL i, j, x;

}ans[N];

void solve() {

    scanf("%lld", &n);

    LL s = 0;

    rep(i, 1, n) scanf("%lld", &a[i]), s += a[i];

    if(s % n != 0) {

        puts("-1");

        return ;

    }

    LL up = s / n; /// 最终都等于 up

    tot = 0;

    rep(i, 2, n) {

        LL x = a[i] / i;

        a[i] %= i;

        if(x == 0) continue;

        ans[++tot] = {i, 1, x};

    }

    rep(i, 2, n) {

        if(a[i] > up) {

            LL need = i - a[i];

            if(a[1] < need) {

                puts("-1"); return ;

            }

            ans[++tot] = {1, i, need};

            a[1] -= need;

            a[i] = 0;

        }

    }

    rep(i, 2, n) {

        if(a[i] < up) {

            ans[++tot] = {1, i, up - a[i]};

        }

    }

    printf("%lld\n", tot);

    rep(i, 1, tot) printf("%lld %lld %lld\n", ans[i].i, ans[i].j, ans[i].x);

}

int main() {

    int _; scanf("%d", &_);
    while(_--) solve();

//    solve();

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

const LL mod = 998244353;

int n, a[N], tot;

struct note {

    int i, j, x;

}ans[N];

void solve() {

    scanf("%d", &n);

    LL s = 0LL;

    rep(i, 1, n) scanf("%d", &a[i]), s += a[i];

    if(s % n != 0) {

        puts("-1"); return ;

    }

    LL up = s / n; /// 最终都等于 up

    tot = 0;

    rep(i, 2, n) {

        if(a[i] > up) {

            if((a[i] - up) % i != 0) {

                puts("-1"); return ;

            }

            ans[++tot] = {i, 1, (a[i] - up) / i};

        }

    }

    rep(i, 2, n) {

        if(a[i] < up) {

            ans[++tot] = {1, i, up - a[i]};

        }

    }

    printf("%d\n", tot);

    rep(i, 1, tot) printf("%d %d %d\n", ans[i].i, ans[i].j, ans[i].x);

}

int main() {

    int _; scanf("%d", &_);
    while(_--) solve();

//    solve();

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

const LL mod = 998244353;

int n, a[N];

void solve() {

    scanf("%d", &n);

    int s = 0;

    rep(i, 1, n) scanf("%d", &a[i]), s += a[i];

    if(s % n) {

        puts("-1"); return ;

    }

    printf("%d\n", 3 * (n - 1));

    s /= n;

    rep(i, 2, n) {

        printf("1 %d %d\n", i, (a[i] % i ? (i - (a[i] % i)) : 0) );

        printf("%d 1 %d\n", i, (a[i] + i - 1) / i);

    }

    rep(i, 2, n) {

        printf("1 %d %d\n", i, s);

    }

}

int main() {

    int _; scanf("%d", &_);
    while(_--) solve();

//    solve();

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

const LL mod = 998244353;

LL n, tot;

LL a[N];

struct note {

    LL i, j, x;

}ans[N];

void solve() {

    scanf("%lld", &n);

    LL s = 0;

    rep(i, 1, n) scanf("%lld", &a[i]), s += a[i];

    if(s % n != 0) {

        puts("-1");

        return ;

    }

    LL up = s / n; /// 最终都等于 up

    tot = 0;

    rep(i, 2, n) {

        LL x = a[i] / i;

        a[1] += x * i;

        a[i] %= i;

        if(x == 0) continue;

        ans[++tot] = {i, 1, x};

    }

    rep(i, 2, n) {

        if(a[i] > up) {

            LL need = i - a[i];

            if(a[1] < need) {

                puts("-1"); return ;

            }

            ans[++tot] = {1, i, need};

            a[1] -= need;

            a[1] += i;

            a[i] = 0;

        }

    }

    rep(i, 2, n) {

        if(a[i] < up) {

            ans[++tot] = {1, i, up - a[i]};

        }

    }

    printf("%lld\n", tot);

    rep(i, 1, tot) printf("%lld %lld %lld\n", ans[i].i, ans[i].j, ans[i].x);

}

int main() {

    int _; scanf("%d", &_);
    while(_--) solve();

//    solve();

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

const LL mod = 998244353;

LL n, tot;

LL a[N];

struct note {

    LL i, j, x;

}ans[N];

void solve() {

    scanf("%lld", &n);

    LL s = 0;

    rep(i, 1, n) scanf("%lld", &a[i]), s += a[i];

    if(s % n != 0) {

        puts("-1");

        return ;

    }

    LL up = s / n; /// 最终都等于 up

    tot = 0;

    rep(i, 2, n) {

        LL x = a[i] / i;

        a[1] += x * i;

        a[i] %= i;

        if(x == 0) continue;

        ans[++tot] = {i, 1, x};

    }

    rep(i, 2, n) {

        if(a[i] > up) {

            LL need = i - a[i];

//            if(a[1] < need) {
//
//                puts("-1"); return ;
//
//            }

            ans[++tot] = {1, i, need};

            a[1] -= need;

            a[1] += i;

            a[i] = 0;

        }

    }

    rep(i, 2, n) {

        if(a[i] < up) {

            ans[++tot] = {1, i, up - a[i]};

        }

    }

    printf("%lld\n", tot);

    rep(i, 1, tot) printf("%lld %lld %lld\n", ans[i].i, ans[i].j, ans[i].x);

}

int main() {

    int _; scanf("%d", &_);
    while(_--) solve();

//    solve();

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

const LL mod = 998244353;

int n, a[N], tot;

struct note {

    int i, j, x;

}ans[N];

void solve() {

    scanf("%d", &n);

    int s = 0;

    rep(i, 1, n) scanf("%d", &a[i]), s += a[i];

    if(s % n != 0) {

        puts("-1"); return ;

    }

    int up = s / n; /// 最终都等于 up

    tot = 0;

    rep(i, 2, n) {

        if(a[i] > up) {

            int dis = a[i] - up;

            int x = (dis + i - 1) / i; ///

            if(x * i > a[i]) {

                puts("-1"); return ;

            }

            ans[++tot] = {i, 1, x};

            a[i] = a[i] - x * i;

        }

    }

    rep(i, 2, n) {

        if(a[i] < up) {

            ans[++tot] = {1, i, up - a[i]};

        }

    }

    printf("%d\n", tot);

    rep(i, 1, tot) printf("%d %d %d\n", ans[i].i, ans[i].j, ans[i].x);

}

int main() {

    int _; scanf("%d", &_);
    while(_--) solve();

//    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
void solve()
{
int n,arr[10001],sum=0;
int a[30001],b[30001],c[30001];
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
    sum+=arr[i];
}
if(sum%n!=0)
{
    cout<<"-1"<<"\n";
    return;
}
int e=sum/n;
int cnt=0;
for(int i=1;i<n;i++)
{
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=((i+1)-(arr[i]%(i+1)))%(i+1);
        arr[i]+=c[cnt];
        arr[0]-=c[cnt];
        int x=(arr[i]/(i+1));
        int m=x*(i+1);
        arr[i]-=m;
        arr[0]+=m;
        //cout<<i+1<<" 1 "<<x<<"\n";
        cnt++;
        a[cnt]=i+1;
        b[cnt]=1;
        c[cnt]=x;
}
for(int i=1;i<n;i++)
{
    if(arr[i]<e)
    {
        //cout<<"1 "<<i+1<<" "<<e-arr[i]<<"\n";
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=e-arr[i];
    }
}
cout<<cnt<<"\n";
for(int i=1;i<=cnt;i++)
    cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<"\n";
}

signed main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);
 int t=1;
cin>>t;
while(t--)
{
  solve();
}
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
void solve()
{
int n,arr[10001],sum=0;
int a[30001],b[30001],c[30001];
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
    sum+=arr[i];
}
if(sum%n!=0)
{
    cout<<"-1"<<"\n";
    return;
}
int e=sum/n;
int cnt=0;
for(int i=1;i<n;i++)
{
    if(arr[i]>e)
    {
        int x=(arr[i]/(i+1));
        int m=x*(i+1);
        arr[i]-=m;
        arr[0]+=m;
        //cout<<i+1<<" 1 "<<x<<"\n";
        cnt++;
        a[cnt]=i+1;
        b[cnt]=1;
        c[cnt]=x;
    }
}
for(int i=1;i<n;i++)
{
    if(arr[i]!=e)
    {
        //cout<<"1 "<<i+1<<" "<<e-arr[i]<<"\n";
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=e-arr[i];
    }
    if(arr[i]>e)
    {
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=(i+1)-(arr[i]%(i+1));
        cnt++;
        a[cnt]=i+1;
        b[cnt]=1;
        c[cnt]=arr[i]/(i+1);
        if(arr[i]!=e)
    {
        //cout<<"1 "<<i+1<<" "<<e-arr[i]<<"\n";
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=e-arr[i];
    }

    }
}
cout<<cnt<<"\n";
for(int i=1;i<=cnt;i++)
    cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<"\n";
}

signed main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);
 int t=1;
cin>>t;
while(t--)
{
  solve();
}
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
void solve()
{
int n,arr[10001],sum=0;
int a[30001],b[30001],c[30001];
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
    sum+=arr[i];
}
if(sum%n!=0)
{
    cout<<"-1"<<"\n";
    return;
}
int e=sum/n;
int cnt=0;
for(int i=1;i<n;i++)
{
    if(arr[i]>e)
    {
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=(i+1)-(arr[i]%(i+1));
        int x=(arr[i]/(i+1));
        int m=x*(i+1);
        arr[i]-=m;
        arr[0]+=m;
        //cout<<i+1<<" 1 "<<x<<"\n";
        cnt++;
        a[cnt]=i+1;
        b[cnt]=1;
        c[cnt]=x;
    }
}
for(int i=1;i<n;i++)
{
    if(arr[i]<e)
    {
        //cout<<"1 "<<i+1<<" "<<e-arr[i]<<"\n";
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=e-arr[i];
    }
}
cout<<cnt<<"\n";
for(int i=1;i<=cnt;i++)
    cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<"\n";
}

signed main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);
 int t=1;
cin>>t;
while(t--)
{
  solve();
}
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
void solve()
{
int n,arr[10001],sum=0;
int a[30001],b[30001],c[30001];
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
    sum+=arr[i];
}
if(sum%n!=0)
{
    cout<<"-1"<<"\n";
    return;
}
int e=sum/n;
int cnt=0;
for(int i=1;i<n;i++)
{
    if(arr[i]>e)
    {
        int x=(arr[i]/(i+1));
        int m=x*(i+1);
        arr[i]-=m;
        arr[0]+=m;
        //cout<<i+1<<" 1 "<<x<<"\n";
        cnt++;
        a[cnt]=i+1;
        b[cnt]=1;
        c[cnt]=x;
    }
}
for(int i=1;i<n;i++)
{
    if(arr[i]<e)
    {
        //cout<<"1 "<<i+1<<" "<<e-arr[i]<<"\n";
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=e-arr[i];
    }
    if(arr[i]>e)
    {
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=(i+1)-(arr[i]%(i+1));
        cnt++;
        a[cnt]=i+1;
        b[cnt]=1;
        c[cnt]=arr[i]/(i+1);
        if(arr[i]!=e)
    {
        //cout<<"1 "<<i+1<<" "<<e-arr[i]<<"\n";
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=e-arr[i];
    }

    }
}
cout<<cnt<<"\n";
for(int i=1;i<=cnt;i++)
    cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<"\n";
}

signed main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);
 int t=1;
cin>>t;
while(t--)
{
  solve();
}
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
void solve()
{
int n,arr[10001],sum=0;
int a[30001],b[30001],c[30001];
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
    sum+=arr[i];
}
if(sum%n!=0)
{
    cout<<"-1"<<"\n";
    return;
}
int e=sum/n;
int cnt=0;
for(int i=1;i<n;i++)
{
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=(i+1)-(arr[i]%(i+1));
        int x=(arr[i]/(i+1));
        int m=x*(i+1);
        arr[i]-=m;
        arr[0]+=m;
        //cout<<i+1<<" 1 "<<x<<"\n";
        cnt++;
        a[cnt]=i+1;
        b[cnt]=1;
        c[cnt]=x;
}
for(int i=1;i<n;i++)
{
    if(arr[i]<e)
    {
        //cout<<"1 "<<i+1<<" "<<e-arr[i]<<"\n";
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=e-arr[i];
    }
}
cout<<cnt<<"\n";
for(int i=1;i<=cnt;i++)
    cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<"\n";
}

signed main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);
 int t=1;
cin>>t;
while(t--)
{
  solve();
}
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
void solve()
{
int n,arr[10001],sum=0;
int a[30001],b[30001],c[30001];
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
    sum+=arr[i];
}
if(sum%n!=0)
{
    cout<<"-1"<<"\n";
    return;
}
int e=sum/n;
int cnt=0;
for(int i=1;i<n;i++)
{
    if(arr[i]>e)
    {
        int x=(arr[i]/(i+1));
        int m=x*(i+1);
        arr[i]-=m;
        arr[0]+=m;
        //cout<<i+1<<" 1 "<<x<<"\n";
        cnt++;
        a[cnt]=i+1;
        b[cnt]=1;
        c[cnt]=x;
    }
}
for(int i=1;i<n;i++)
{
    if(arr[i]!=e)
    {
        //cout<<"1 "<<i+1<<" "<<e-arr[i]<<"\n";
        cnt++;
        a[cnt]=1;
        b[cnt]=i+1;
        c[cnt]=e-arr[i];
    }
}
cout<<cnt<<"\n";
for(int i=1;i<=cnt;i++)
    cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<"\n";
}

signed main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);
 int t=1;
cin>>t;
while(t--)
{
  solve();
}
  return 0;
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N*4][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int j=1;j<=100;j++)
        {
            for (int i=2;i<=n;i++)
            {
                if (a[i]>sta)
                {
                    if (i>a[i]) continue;
                    if (a[i]%i>=sta)
                    {
                        ans++;
                        st[ans][0]=i;
                        st[ans][1]=1;
                        st[ans][2]=a[i]/i;
                        a[1]+=a[i]/i*i;
                        a[i]=a[i]%i;
                    }else
                    {
                        ans++;
                        st[ans][0]=i;
                        st[ans][1]=1;
                        st[ans][2]=(a[i]-sta)/i;
                        a[1]+=st[ans][2]*i;
                        a[i]-=st[ans][2]*i;
                        if (a[i]>sta)
                        {
                            if (a[i]>=i)
                            {
                                st[ans][2]++;
                                a[1]+=i;
                                a[i]-=i;
                            }
                        }
                    }
                }
            }
        }
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (a[1]>i-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i-a[i];
                    a[1]-=i-a[i];
                    a[i]+=i-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }
            }
        }
        int p=1;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta) p=0;
            if (a[i]<sta)
            {
                ans++;
                st[ans][0]=1;
                st[ans][1]=i;
                st[ans][2]=sta-a[i];
                a[1]-=sta-a[i];
                a[i]=sta;
            }
            if (a[1]<0) p=0;
        }
        if (!p) printf("-1\n");
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N*4][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (i>a[i]) continue;
                if (a[i]%i>=sta)
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=a[i]/i;
                    a[1]+=a[i]/i*i;
                    a[i]=a[i]%i;
                }else
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=(a[i]-sta)/i;
                    a[1]+=st[ans][2]*i;
                    a[i]-=st[ans][2]*i;
                    if (a[i]>sta)
                    {
                        if (a[i]>=i)
                        {
                            st[ans][2]++;
                            a[1]+=i;
                            a[i]-=i;
                        }
                    }
                }
            }
        }
        for (int j=1;j<=100;j++) for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (a[1]>=i+sta-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i+sta-a[i];
                    a[1]-=i+sta-a[i];
                    a[i]+=i+sta-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }else if (a[1]>=i-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i-a[i];
                    a[1]-=i-a[i];
                    a[i]+=i-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }
            }
        }
        int p=1;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta) p=0;
            if (a[i]<sta)
            {
                ans++;
                st[ans][0]=1;
                st[ans][1]=i;
                st[ans][2]=sta-a[i];
                a[1]-=sta-a[i];
                a[i]=sta;
            }
            if (a[1]<0) p=0;
        }
        if (!p) printf("-1\n");
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N*4][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (i>a[i]) continue;
                if (a[i]%i>=sta)
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=a[i]/i;
                    a[1]+=a[i]/i*i;
                    a[i]=a[i]%i;
                }else
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=(a[i]-sta)/i;
                    a[1]+=st[ans][2]*i;
                    a[i]-=st[ans][2]*i;
                    if (a[i]>sta)
                    {
                        if (a[i]>=i)
                        {
                            st[ans][2]++;
                            a[1]+=i;
                            a[i]-=i;
                        }
                    }
                }
            }
        }
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (a[1]>=i+sta-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i+sta-a[i];
                    a[1]-=i+sta-a[i];
                    a[i]+=i+sta-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }else if (a[1]>i-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i-a[i];
                    a[1]-=i-a[i];
                    a[i]+=i-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }
            }
        }
        int p=1;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta) p=0;
            if (a[i]<sta)
            {
                ans++;
                st[ans][0]=1;
                st[ans][1]=i;
                st[ans][2]=sta-a[i];
                a[1]-=sta-a[i];
                a[i]=sta;
            }
            if (a[1]<0) p=0;
        }
        if (!p) printf("-1\n");
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (i>a[i]) continue;
                if (a[i]%i>=sta)
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=a[i]/i;
                    a[1]+=a[i]/i*i;
                    a[i]=a[i]%i;
                }else
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=(a[i]-sta)/i;
                    a[1]+=st[ans][2]*i;
                    a[i]-=st[ans][2]*i;
                    if (a[i]>sta)
                    {
                        if (a[i]>=i)
                        {
                            st[ans][2]++;
                            a[1]+=i;
                            a[i]-=i;
                        }
                    }
                }
            }
        }
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (a[1]>=i+sta-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i+sta-a[i];
                    a[1]-=i+sta-a[i];
                    a[i]+=i+sta-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }else if (a[1]>i-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i-a[i];
                    a[1]-=i-a[i];
                    a[i]+=i-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }
            }
        }
        int p=1;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta) p=0;
            if (a[i]<sta)
            {
                ans++;
                st[ans][0]=1;
                st[ans][1]=i;
                st[ans][2]=sta-a[i];
                a[1]-=sta-a[i];
                a[i]=sta;
            }
            if (a[1]<0) p=0;
        }
        if (!p) printf("-1\n");
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N*4][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int j=1;j<=100;j++)
        {
            for (int i=2;i<=n;i++)
            {
                if (a[i]>sta)
                {
                    if (i>a[i]) continue;
                    if (a[i]%i>=sta)
                    {
                        ans++;
                        st[ans][0]=i;
                        st[ans][1]=1;
                        st[ans][2]=a[i]/i;
                        a[1]+=a[i]/i*i;
                        a[i]=a[i]%i;
                    }else
                    {
                        ans++;
                        st[ans][0]=i;
                        st[ans][1]=1;
                        st[ans][2]=(a[i]-sta)/i;
                        a[1]+=st[ans][2]*i;
                        a[i]-=st[ans][2]*i;
                        if (a[i]>sta)
                        {
                            if (a[i]>=i)
                            {
                                st[ans][2]++;
                                a[1]+=i;
                                a[i]-=i;
                            }
                        }
                    }
                }
            }
        }
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (a[1]>=i+sta-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i+sta-a[i];
                    a[1]-=i+sta-a[i];
                    a[i]+=i+sta-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }else if (a[1]>i-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i-a[i];
                    a[1]-=i-a[i];
                    a[i]+=i-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }
            }
        }
        int p=1;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta) p=0;
            if (a[i]<sta)
            {
                ans++;
                st[ans][0]=1;
                st[ans][1]=i;
                st[ans][2]=sta-a[i];
                a[1]-=sta-a[i];
                a[i]=sta;
            }
            if (a[1]<0) p=0;
        }
        if (!p) printf("-1\n");
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (i>a[i]) continue;
                if (a[i]%i>=sta)
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=a[i]/i;
                    a[1]+=a[i]/i*i;
                    a[i]=a[i]%i;
                }else
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    if ((a[i]-sta)%i==0) st[ans][2]=(a[i]-sta)/i;
                    else st[ans][2]=(a[i]-sta)/i+1;
                    a[1]+=st[ans][2]*i;
                    a[i]-=st[ans][2]*i;
                }
            }
        }
        int p=1;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta) p=0;
            if (a[i]<sta)
            {
                ans++;
                st[ans][0]=1;
                st[ans][1]=i;
                st[ans][2]=sta-a[i];
                a[1]-=sta-a[i];
                a[i]=sta;
            }
            if (a[1]<0) p=0;
        }
        if (!p) printf("-1\n");
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N*4][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int j=1;j<=100;j++)
        {
            for (int i=2;i<=n;i++)
            {
                if (a[i]>sta)
                {
                    if (i>a[i]) continue;
                    if (a[i]%i>=sta)
                    {
                        ans++;
                        st[ans][0]=i;
                        st[ans][1]=1;
                        st[ans][2]=a[i]/i;
                        a[1]+=a[i]/i*i;
                        a[i]=a[i]%i;
                    }else
                    {
                        ans++;
                        st[ans][0]=i;
                        st[ans][1]=1;
                        st[ans][2]=(a[i]-sta)/i;
                        a[1]+=st[ans][2]*i;
                        a[i]-=st[ans][2]*i;
                        if (a[i]>sta)
                        {
                            if (a[i]>=i)
                            {
                                st[ans][2]++;
                                a[1]+=i;
                                a[i]-=i;
                            }
                        }
                    }
                }
            }
        }
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (a[1]>=i-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i-a[i];
                    a[1]-=i-a[i];
                    a[i]+=i-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }
            }
        }
        int p=1;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta) p=0;
            if (a[i]<sta)
            {
                ans++;
                st[ans][0]=1;
                st[ans][1]=i;
                st[ans][2]=sta-a[i];
                a[1]-=sta-a[i];
                a[i]=sta;
            }
            if (a[1]<0) p=0;
        }
        if (!p) printf("-1\n");
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N*4][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int i=2;i<=n;i++)
        {
            ans++;
            st[ans][0]=1;
            st[ans][1]=i;
            st[ans][2]=i-a[i]%i;
            a[i]+=i-a[i]%i;
            ans++;
            st[ans][0]=i;
            st[ans][1]=1;
            st[ans][2]=a[i]/i;
        }
        for (int i=2;i<=n;i++)
        {
            ans++;
            st[ans][0]=1;
            st[ans][1]=i;
            st[ans][2]=sta;
        }
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N*4][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (i>a[i]) continue;
                if (a[i]%i>=sta)
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=a[i]/i;
                    a[1]+=a[i]/i*i;
                    a[i]=a[i]%i;
                }else
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=(a[i]-sta)/i;
                    a[1]+=st[ans][2]*i;
                    a[i]-=st[ans][2]*i;
                    if (a[i]>sta)
                    {
                        if (a[i]>=i)
                        {
                            st[ans][2]++;
                            a[1]+=i;
                            a[i]-=i;
                        }
                    }
                }
            }
        }
        for (int j=1;j<=100;j++) for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (a[1]>=i-a[i])
                {
                    ans++;
                    st[ans][0]=1;
                    st[ans][1]=i;
                    st[ans][2]=i-a[i];
                    a[1]-=i-a[i];
                    a[i]+=i-a[i];
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=1;
                    a[1]+=i;
                    a[i]-=i;
                }
            }
        }
        int p=1;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta) p=0;
            if (a[i]<sta)
            {
                ans++;
                st[ans][0]=1;
                st[ans][1]=i;
                st[ans][2]=sta-a[i];
                a[1]-=sta-a[i];
                a[i]=sta;
            }
            if (a[1]<0) p=0;
        }
        if (!p) printf("-1\n");
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N*4][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int i=2;i<=n;i++)
        {
            ans++;
            st[ans][0]=1;
            st[ans][1]=i;
            st[ans][2]=(i-a[i]%i)%i;
            a[i]+=(i-a[i]%i)%i;
            ans++;
            st[ans][0]=i;
            st[ans][1]=1;
            st[ans][2]=a[i]/i;
        }
        for (int i=2;i<=n;i++)
        {
            ans++;
            st[ans][0]=1;
            st[ans][1]=i;
            st[ans][2]=sta;
        }
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int a[N],st[N][3];
int main()
{
    int tt;
    scanf("%d",&tt);
    /*for (int i=1;i<=10000;i++)
    {
        for (int j=1;j*j<=i;j++)
        {
            if (i%j==0)
            {
                l[i]=j;
                r[i]=i/j;
            }
        }
    }*/
    while (tt)
    {
        tt--;
        int n;
        scanf("%d",&n);
        int sum=0;
        for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        if (sum%n)
        {
            printf("-1\n");
            continue;
        }
        int sta=sum/n;
        int ans=0;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta)
            {
                if (i>a[i]) continue;
                if (a[i]%i>=sta)
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=a[i]/i;
                    a[1]+=a[i]/i*i;
                    a[i]=a[i]%i;
                }else
                {
                    ans++;
                    st[ans][0]=i;
                    st[ans][1]=1;
                    st[ans][2]=(a[i]-sta)/i;
                    a[1]+=st[ans][2]*i;
                    a[i]-=st[ans][2]*i;
                    if (a[i]>sta)
                    {
                        if (a[i]>=i)
                        {
                            st[ans][2]++;
                            a[1]+=i;
                            a[i]-=i;
                        }
                    }
                }
            }
        }
        int p=1;
        for (int i=2;i<=n;i++)
        {
            if (a[i]>sta) p=0;
            if (a[i]<sta)
            {
                ans++;
                st[ans][0]=1;
                st[ans][1]=i;
                st[ans][2]=sta-a[i];
                a[1]-=sta-a[i];
                a[i]=sta;
            }
            if (a[1]<0) p=0;
        }
        if (!p) printf("-1\n");
        {
            printf("%d\n",ans);
            for (int i=1;i<=ans;i++) printf("%d %d %d\n",st[i][0],st[i][1],st[i][2]);
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define ALL(v) (v).begin(),(v).end()
using ll=long long;
const int N=500100,mod=998244353;

ll tt,n;

void fn(){
    cin>>n;
    ll a[n+5],sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%n){
        cout<<"-1\n";
        return ;
    }

    vector<pair<pair<int,int>,ll>>p;

    for(int i=2;i<=n;i++){
        if(a[i]%i){
            p.pb({{i,1},a[i]%i});
            a[1]+=a[i]%i;
            a[i]-=a[i]%i;
        }
        p.pb({{i,1},a[i]/i});
        a[1]+=a[i]/i;
        //cout<<a[i]<<endl;
    }

    for(int i=2;i<=n;i++){
        p.pb({{1,i},sum/n});
    }
    cout<<(int)p.size()<<endl;
    for(int i=0;i<(int)p.size();i++){
        cout<<p[i].f.f<<" "<<p[i].f.s<<" "<<p[i].s<<endl;
    }
    return ;
}

int main(){
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    cin>>tt;
    while(tt--) fn();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define ALL(v) (v).begin(),(v).end()
using ll=long long;
const int N=500100,mod=998244353;

ll tt,n;

void fn(){
    cin>>n;
    ll a[n+5],sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%n){
        cout<<"-1\n";
        return ;
    }

    vector<pair<pair<int,int>,ll>>p;

    for(int i=2;i<=n;i++){
        if(a[i]%i){
            p.pb({{1,i},a[i]%i});
            a[1]+=a[i]%i;
            a[i]-=a[i]%i;
        }
        p.pb({{1,i},a[i]/i});
    }

    for(int i=2;i<=n;i++){
        p.pb({{1,i},sum/n});
    }
    cout<<(int)p.size()<<endl;
    for(int i=0;i<(int)p.size();i++){
        cout<<p[i].f.f<<" "<<p[i].f.s<<" "<<p[i].s<<endl;
    }
    return ;
}

int main(){
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    cin>>tt;
    while(tt--) fn();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define ALL(v) (v).begin(),(v).end()
using ll=long long;
const int N=500100,mod=998244353;

ll tt,n;

void fn(){
    cin>>n;
    ll a[n+5],sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%n){
        cout<<"-1\n";
        return ;
    }

    vector<pair<pair<int,int>,ll>>p;

    for(int i=2;i<=n;i++){
        if(a[i]%i){
            p.pb({{1,i},i-a[i]%i});
            a[i]+=(i-a[i]%i);
        }
        p.pb({{i,1},a[i]/i});
    }

    for(int i=2;i<=n;i++){
        p.pb({{1,i},sum/n});
    }
    cout<<(int)p.size()<<endl;
    for(int i=0;i<(int)p.size();i++){
        cout<<p[i].f.f<<" "<<p[i].f.s<<" "<<p[i].s<<endl;
    }
    return ;
}

int main(){
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    cin>>tt;
    while(tt--) fn();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define ALL(v) (v).begin(),(v).end()
using ll=long long;
const int N=500100,mod=998244353;

ll tt,n;

void fn(){
    cin>>n;
    ll a[n+5],sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%n){
        cout<<"-1\n";
        return ;
    }

    vector<pair<pair<int,int>,ll>>p;

    for(int i=2;i<=n;i++){
        if(a[i]%i){
            p.pb({{i,1},a[i]%i});
            a[i]-=a[i]%i;
        }
        if(a[i])
            p.pb({{i,1},a[i]/i});
    }

    for(int i=2;i<=n;i++){
        p.pb({{1,i},sum/n});
    }
    cout<<(int)p.size()<<endl;
    for(int i=0;i<(int)p.size();i++){
        cout<<p[i].f.f<<" "<<p[i].f.s<<" "<<p[i].s<<endl;
    }
    return ;
}

int main(){
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    cin>>tt;
    while(tt--) fn();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define ALL(v) (v).begin(),(v).end()
using ll=long long;
const int N=500100,mod=998244353;

ll tt,n;

void fn(){
    cin>>n;
    ll a[n+5],sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%n){
        cout<<"-1\n";
        return ;
    }

    vector<pair<pair<int,int>,ll>>p;

    for(int i=2;i<=n;i++){
        if(a[i]%i){
            p.pb({{i,1},a[i]%i});
            a[1]+=a[i]%i;
            a[i]-=a[i]%i;
        }
        p.pb({{i,1},a[i]/i});
        a[1]+=a[i];
        //cout<<a[1]<<endl;
    }

    for(int i=2;i<=n;i++){
        p.pb({{1,i},sum/n});
    }
    cout<<(int)p.size()<<endl;
    for(int i=0;i<(int)p.size();i++){
        cout<<p[i].f.f<<" "<<p[i].f.s<<" "<<p[i].s<<endl;
    }
    return ;
}

int main(){
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    cin>>tt;
    while(tt--) fn();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define ALL(v) (v).begin(),(v).end()
using ll=long long;
const int N=500100,mod=998244353;

ll tt,n;

void fn(){
    cin>>n;
    ll a[n+5],sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%n){
        cout<<"-1\n";
        return ;
    }

    vector<pair<pair<int,int>,ll>>p;

    for(int i=2;i<=n;i++){
        if(a[i]%i){
            p.pb({{i,1},a[i]%i});
            a[1]+=a[i]%i;
            a[i]-=a[i]%i;
        }
        p.pb({{i,1},a[i]/i});
        //cout<<a[i]<<endl;
    }

    for(int i=2;i<=n;i++){
        p.pb({{1,i},sum/n});
    }
    cout<<(int)p.size()<<endl;
    for(int i=0;i<(int)p.size();i++){
        cout<<p[i].f.f<<" "<<p[i].f.s<<" "<<p[i].s<<endl;
    }
    return ;
}

int main(){
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    cin>>tt;
    while(tt--) fn();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pil;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define g(x) greater<x>()
#define SPEED ios::sync_with_stdio(false)
const int mod=1e9+7;
const int maxn=3e5+100;
int t,T,n,k;
int A[maxn];
int B[maxn];
int main()
{
    SPEED;
    cin>>T;
    while(T--)
    {
        cin>>n;
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            cin>>A[i];
            sum+=A[i];
            B[i]=A[i];
        }
        if(sum%n)
        {
            cout<<-1<<endl;
            continue;
        }
        sum/=n;
        for(int i=2;i<=n;i++)
        {
            int x=A[i]/i*i;
            A[1]+=x;
            A[i]-=x;
        }
        int ok=1;
        for(int i=n;i>1;i--)
        {
            if(A[i]>sum) ok=0;
            A[1]-=sum-A[i];
            if(A[1]<0) ok=0;
            if(!ok) break;
        }
        if(ok)
        {
            for(int i=2;i<=n;i++)
            {
                int x=B[i]/i*i;
                B[1]+=x;
                B[i]-=x;
                cout<<i<<" "<<1<<" "<<x/i<<endl;
            }
            for(int i=n;i>1;i--)
            {
                int x=sum-A[i];
                A[1]-=x;
                cout<<1<<" "<<i<<" "<<x<<endl;
            }
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pil;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define g(x) greater<x>()
#define SPEED ios::sync_with_stdio(false)
const int mod=1e9+7;
const int maxn=3e5+100;
int t,T,n,k;
int A[maxn];
int main()
{
    SPEED;
    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)
        {
            cout<<-1<<"\n";
            continue;
        }
        sum/=n;
        cout<<3*(n-1)<<"\n";
        for(int i=2;i<=n;i++)
        {
            int d=(i-A[i]%i)%i;
            A[i]+=d;
            A[1]-=d;
            cout<<1<<" "<<i<<" "<<d<<"\n";
            int x=A[i]/i;
            A[1]+=A[i];
            A[i]=0;
            cout<<i<<" "<<1<<" "<<x<<"\n";
        }
        for(int i=2;i<=n;i++)
            cout<<1<<" "<<i<<" "<<sum<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pil;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define g(x) greater<x>()
#define SPEED ios::sync_with_stdio(false)
const int mod=1e9+7;
const int maxn=3e5+100;
int t,T,n,k;
int A[maxn];
int main()
{
    SPEED;
    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)
        {
            cout<<-1<<endl;
            continue;
        }
        sum/=n;
        cout<<3*(n-1)<<endl;
        for(int i=2;i<=n;i++)
        {
            int d=i-A[i]%i;
            A[i]+=d;
            A[1]-=d;
            cout<<1<<" "<<i<<" "<<d<<endl;
            int x=A[i]/i;
            A[1]+=A[i];
            A[i]=0;
            cout<<i<<" "<<1<<" "<<x<<endl;
        }
        for(int i=2;i<=n;i++)
            cout<<1<<" "<<i<<" "<<sum<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pil;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define g(x) greater<x>()
#define SPEED ios::sync_with_stdio(false)
const int mod=1e9+7;
const int maxn=3e5+100;
int t,T,n,k;
int A[maxn];
int B[maxn];
int main()
{
    SPEED;
    cin>>T;
    while(T--)
    {
        cin>>n;
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            cin>>A[i];
            sum+=A[i];
            B[i]=A[i];
        }
        if(sum%n)
        {
            cout<<-1<<endl;
            continue;
        }
        sum/=n;
        for(int i=2;i<=n;i++)
        {
            int x=A[i]/i*i;
            A[1]+=x;
            A[i]-=x;
        }
        int ok=1;
        for(int i=n;i>1;i--)
        {
            if(A[i]>sum) ok=0;
            A[1]-=sum-A[i];
            if(A[1]<0) ok=0;
            if(!ok) break;
        }
        if(ok)
        {
            cout<<2*(n-1)<<endl;
            for(int i=2;i<=n;i++)
            {
                int x=B[i]/i*i;
                B[1]+=x;
                B[i]-=x;
                cout<<i<<" "<<1<<" "<<x/i<<endl;
            }
            for(int i=n;i>1;i--)
            {
                int x=sum-B[i];
                B[1]-=x;
                B[i]+=x;
                cout<<1<<" "<<i<<" "<<x<<endl;
            }
            // for(int i=1;i<=n;i++)
            //     cout<<B[i]<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pil;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define g(x) greater<x>()
#define SPEED ios::sync_with_stdio(false)
const int mod=1e9+7;
const int maxn=3e5+100;
int t,T,n,k;
int A[maxn];
int B[maxn];
int main()
{
    SPEED;
    cin>>T;
    while(T--)
    {
        cin>>n;
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            cin>>A[i];
            sum+=A[i];
            B[i]=A[i];
        }
        if(sum%n)
        {
            cout<<-1<<endl;
            continue;
        }
        sum/=n;
        for(int i=2;i<=n;i++)
        {
            int x=A[i]/i*i;
            A[1]+=x;
            A[i]-=x;
        }
        int ok=1;
        for(int i=n;i>1;i--)
        {
            if(A[i]>sum) ok=0;
            A[1]-=sum-A[i];
            if(A[1]<0) ok=0;
            if(!ok) break;
        }
        if(!ok)
        {
            cout<<-1<<endl;
            continue;
        }
        if(ok)
        {
            cout<<2*(n-1)<<endl;
            for(int i=2;i<=n;i++)
            {
                int x=B[i]/i*i;
                B[1]+=x;
                B[i]-=x;
                cout<<i<<" "<<1<<" "<<x/i<<endl;
            }
            for(int i=n;i>1;i--)
            {
                int x=sum-B[i];
                B[1]-=x;
                B[i]+=x;
                cout<<1<<" "<<i<<" "<<x<<endl;
            }
            // for(int i=1;i<=n;i++)
            //     cout<<B[i]<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pil;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define g(x) greater<x>()
#define SPEED ios::sync_with_stdio(false)
const int mod=1e9+7;
const int maxn=3e5+100;
int t,T,n,k;
int A[maxn];
int main()
{
    SPEED;
    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)
        {
            cout<<-1<<endl;
            continue;
        }
        sum/=n;
        cout<<3*(n-1)<<endl;
        for(int i=2;i<=n;i++)
        {
            int d=(i-A[i]%i)%i;
            A[i]+=d;
            A[1]-=d;
            cout<<1<<" "<<i<<" "<<d<<endl;
            int x=A[i]/i;
            A[1]+=A[i];
            A[i]=0;
            cout<<i<<" "<<1<<" "<<x<<endl;
        }
        for(int i=2;i<=n;i++)
            cout<<1<<" "<<i<<" "<<sum<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pil;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define g(x) greater<x>()
#define SPEED ios::sync_with_stdio(false)
const int mod=1e9+7;
const int maxn=3e5+100;
int t,T,n,k;
int A[maxn];
int B[maxn];
int main()
{
    SPEED;
    cin>>T;
    while(T--)
    {
        cin>>n;
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            cin>>A[i];
            sum+=A[i];
            B[i]=A[i];
        }
        if(sum%n)
        {
            cout<<-1<<endl;
            continue;
        }
        sum/=n;
        int cnt=0;
        for(int i=2;i<=n;i++)
        {
            int d=(A[i]+i-1)/i*i-A[i];
            if(d<=A[1])
            {
                A[i]+=d;
                A[1]-=d;
                cnt++;
            }
            int x=A[i]/i*i;
            A[1]+=x;
            A[i]-=x;
        }
        int ok=1;
        for(int i=n;i>1;i--)
        {
            if(A[i]>sum) ok=0;
            A[1]-=(sum-A[i]);
            if(A[1]<0) ok=0;
            if(!ok) break;
        }
        if(!ok)
        {
            cout<<-1<<endl;
            continue;
        }
        if(ok)
        {
            cout<<2*(n-1)+cnt<<endl;
            for(int i=2;i<=n;i++)
            {
                int d=(B[i]+i-1)/i*i-B[i];
                if(d<=B[1])
                {
                    B[i]+=d;
                    B[1]-=d;
                    //cout<<"fuck "<<B[1]<<endl;
                    cout<<1<<" "<<i<<" "<<d<<endl;
                }
                int x=B[i]/i*i;
                B[1]+=x;
                B[i]-=x;
                cout<<i<<" "<<1<<" "<<x/i<<endl;
            }
            // for(int i=2;i<=n;i++)
            // {
            //     int x=B[i]/i*i;
            //     B[1]+=x;
            //     B[i]-=x;
            //     cout<<i<<" "<<1<<" "<<x/i<<endl;
            // }
            for(int i=n;i>1;i--)
            {
                int x=sum-B[i];
                B[1]-=x;
                B[i]+=x;
                cout<<1<<" "<<i<<" "<<x<<endl;
            }
            // for(int i=1;i<=n;i++)
            //     cout<<B[i]<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pil;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define g(x) greater<x>()
#define SPEED ios::sync_with_stdio(false)
const int mod=1e9+7;
const int maxn=3e5+100;
int t,T,n,k;
int A[maxn];
int B[maxn];
int main()
{
    SPEED;
    cin>>T;
    while(T--)
    {
        cin>>n;
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            cin>>A[i];
            sum+=A[i];
            B[i]=A[i];
        }
        if(sum%n)
        {
            cout<<-1<<endl;
            continue;
        }
        sum/=n;
        int cnt=0;
        for(int i=2;i<=n;i++)
        {
            int d=(A[i]+i-1)/i*i-A[i];
            if(d<=A[1])
            {
                A[i]+=d;
                A[1]-=d;
                cnt++;
            }
            int x=A[i]/i*i;
            A[1]+=x;
            A[i]-=x;
        }
        int ok=1;
        for(int i=n;i>1;i--)
        {
            if(A[i]>sum) ok=0;
            A[1]-=(sum-A[i]);
            if(A[1]<0) ok=0;
            if(!ok) break;
        }
        if(!ok)
        {
            cout<<-1<<endl;
            continue;
        }
        if(ok)
        {
            cout<<2*(n-1)+cnt<<endl;
            for(int i=2;i<=n;i++)
            {
                int d=(B[i]+i-1)/i*i-B[i];
                if(d<=B[1])
                {
                    B[i]+=d;
                    B[1]-=d;
                    cout<<1<<" "<<i<<" "<<d<<endl;
                }
                int x=B[i]/i*i;
                B[1]+=x;
                B[i]-=x;
            }
            for(int i=2;i<=n;i++)
            {
                int x=B[i]/i*i;
                B[1]+=x;
                B[i]-=x;
                cout<<i<<" "<<1<<" "<<x/i<<endl;
            }
            for(int i=n;i>1;i--)
            {
                int x=sum-B[i];
                B[1]-=x;
                B[i]+=x;
                cout<<1<<" "<<i<<" "<<x<<endl;
            }
            // for(int i=1;i<=n;i++)
            //     cout<<B[i]<<endl;
        }
    }
}


#include<bits/stdc++.h>
//#include<conio.h>
using namespace std;    // instances like vi,stack,queue, cin ,cout OF STANDARD NAMESPACE (one predefined).

#define ff first
#define ss second
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define pb push_back
//  for counting setbits -> __builtin_popcountll(x)
// for counting zerobits -> __builtin_ctzll(x)

#define fastio ios_base::sync_with_stdio(false);        cin.tie(NULL); //(unties i/o buffer).
            // DON'T USE SCANF/PRINTF WITH IT (c/c++ -> seperates buffer).

// (first place constants class/struct, then functions (using them))

// ** Here can only DEFINE (variable initialise while defining) , CAN'T SET VALUE.
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2e5 + 5;
int ar[N] , ans[N];

int32_t main(){
    fastio

    #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
    #endif

     // ***** AC_chahiye EK BAR MEIN

    int t_c_ = 1;
    cin>>t_c_;

     // BEGIN CODE HERE

    while(t_c_--){
        int n;
        cin >> n;

        int sum = 0;
        for(int i = 1; i <= n; i++){
            cin >> ar[i];

            sum += ar[i];

            ans[i] = ans[i + n] = 0;
        }

        if(sum%n){
            cout<<"-1\n";
            continue;
        }

        int avg = sum/n;

        int pos = 1;
        for(int i = 2 ; i <= n; i++){
            if(ar[i] > avg){
                ans[i] = (ar[i]-avg + i-1)/i;
                ar[i] -= i*ans[i];

                if(ar[i] < 0){
                    pos = 0;
                    break;
                }
            }
            ans[i + n] = avg - ar[i];
        }

        if(!pos){
            cout<<"-1\n";
            continue;
        }

        cout<<2*n<<'\n';
        for(int i = 1; i <= n; i++)
            cout<<i<<" 1 "<<ans[i]<<'\n';
        for(int i = 1; i <= n; i++)
            cout<<"1 "<<i<<" "<<ans[i + n]<<'\n';
    }
    //getch();
}


#include<bits/stdc++.h>
//#include<conio.h>
using namespace std;    // instances like vi,stack,queue, cin ,cout OF STANDARD NAMESPACE (one predefined).

#define ff first
#define ss second
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define pb push_back
//  for counting setbits -> __builtin_popcountll(x)
// for counting zerobits -> __builtin_ctzll(x)

#define fastio ios_base::sync_with_stdio(false);        cin.tie(NULL); //(unties i/o buffer).
            // DON'T USE SCANF/PRINTF WITH IT (c/c++ -> seperates buffer).

// (first place constants class/struct, then functions (using them))

// ** Here can only DEFINE (variable initialise while defining) , CAN'T SET VALUE.
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2e5 + 5;
int ar[N] , ans[N];

int32_t main(){
    fastio

    #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
    #endif

     // ***** AC_chahiye EK BAR MEIN

    int t_c_ = 1;
    cin>>t_c_;

     // BEGIN CODE HERE

    while(t_c_--){
        int n;
        cin >> n;
        for(int i = 1; i <= 2*n; i++)
            ans[i] = 0;

        int sum = 0;
        for(int i = 1; i <= n; i++){
            cin >> ar[i];
            sum += ar[i];
        }

        if(sum%n){
            cout<<"-1\n";
            continue;
        }

        int avg = sum/n;

        int pos = 1;
        for(int i = 2 ; i <= n; i++){
            if(ar[i] > avg){
                ans[i] = (ar[i]-avg + i-1)/i;
                ar[i] -= i*ans[i];

                if(ar[i] < 0){
                    pos = 0;
                    break;
                }
            }
            ans[i + n] = avg - ar[i];
        }

        if(!pos){
            cout<<"-1\n";
            continue;
        }

        cout<<2*n - 2<<'\n';
        for(int i = 2; i <= n; i++)
            cout<<i<<" 1 "<<ans[i]<<'\n';
        for(int i = 2; i <= n; i++)
            cout<<"1 "<<i<<" "<<ans[i + n]<<'\n';
    }
    //getch();
}


#include<bits/stdc++.h>
//#include<conio.h>
using namespace std;    // instances like vi,stack,queue, cin ,cout OF STANDARD NAMESPACE (one predefined).

#define ff first
#define ss second
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define pb push_back
//  for counting setbits -> __builtin_popcountll(x)
// for counting zerobits -> __builtin_ctzll(x)

#define fastio ios_base::sync_with_stdio(false);        cin.tie(NULL); //(unties i/o buffer).
            // DON'T USE SCANF/PRINTF WITH IT (c/c++ -> seperates buffer).

// (first place constants class/struct, then functions (using them))

// ** Here can only DEFINE (variable initialise while defining) , CAN'T SET VALUE.
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2e5 + 5;
int ar[N] , ans[N];

int32_t main(){
    fastio

    #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
    #endif

     // ***** AC_chahiye EK BAR MEIN

    int t_c_ = 1;
    cin>>t_c_;

     // BEGIN CODE HERE

    while(t_c_--){
        int n;
        cin >> n;
        int sum = 0;

        for(int i = 1; i <= n; i++){
            cin >> ar[i];
            sum += ar[i];
        }

        if(sum%n){
            cout<<"-1\n";
            continue;
        }

        cout<<3*(n - 1)<<'\n';

        for(int i = 2; i <= n; i++){
            int x = (i - (ar[i]%i))%i;
            cout<<"1 "<<i<<" "<<x<<'\n';
            ar[1] -= x;
            ar[i] += x;
            cout<<i<<" 1 "<<ar[i]/i<<'\n';
        }

        for(int i = 2; i <= n; i++){
            cout<<"1 "<<i<<" "<<sum/n<<'\n';
        }

    }
    //getch();
}


#include<bits/stdc++.h>
//#include<conio.h>
using namespace std;    // instances like vi,stack,queue, cin ,cout OF STANDARD NAMESPACE (one predefined).

#define ff first
#define ss second
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define pb push_back
//  for counting setbits -> __builtin_popcountll(x)
// for counting zerobits -> __builtin_ctzll(x)

#define fastio ios_base::sync_with_stdio(false);        cin.tie(NULL); //(unties i/o buffer).
            // DON'T USE SCANF/PRINTF WITH IT (c/c++ -> seperates buffer).

// (first place constants class/struct, then functions (using them))

// ** Here can only DEFINE (variable initialise while defining) , CAN'T SET VALUE.
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2e5 + 5;
int ar[N] , ans[N];

int32_t main(){
    fastio

    #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
    #endif

     // ***** AC_chahiye EK BAR MEIN

    int t_c_ = 1;
    cin>>t_c_;

     // BEGIN CODE HERE

    while(t_c_--){
        int n;
        cin >> n;

        int sum = 0;
        for(int i = 1; i <= n; i++){
            cin >> ar[i];

            sum += ar[i];

            ans[i] = ans[2*i] = 0;
        }

        if(sum%n){
            cout<<"-1\n";
            continue;
        }

        int pos = 1;
        for(int i = 2 ; i <= n; i++){
            if(ar[i] > sum/n){
                if(i > ar[i]){
                    pos = 0;
                    break;
                }
                else{
                    ans[i] = (ar[i]-(sum/n) + i-1)/i;
                    ar[i] -= ans[i]*i;
                }

            }
            ans[i + n] = (sum/n - ar[i]);
        }

        if(!pos){
            cout<<"-1\n";
            continue;
        }

        cout<<2*n<<'\n';
        for(int i = 1; i <= 2*n; i++){
            if(i <= n)
                cout<<i<<" 1";
            else
                cout<<"1 "<<i-n;

            cout<<" "<<ans[i]<<'\n';
        }
    }
    //getch();
}


#include<bits/stdc++.h>
//#include<conio.h>
using namespace std;    // instances like vi,stack,queue, cin ,cout OF STANDARD NAMESPACE (one predefined).

#define ff first
#define ss second
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define pb push_back
//  for counting setbits -> __builtin_popcountll(x)
// for counting zerobits -> __builtin_ctzll(x)

#define fastio ios_base::sync_with_stdio(false);        cin.tie(NULL); //(unties i/o buffer).
            // DON'T USE SCANF/PRINTF WITH IT (c/c++ -> seperates buffer).

// (first place constants class/struct, then functions (using them))

// ** Here can only DEFINE (variable initialise while defining) , CAN'T SET VALUE.
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2e5 + 5;
int ar[N] , ans[N];

int32_t main(){
    fastio

    #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
    #endif

     // ***** AC_chahiye EK BAR MEIN

    int t_c_ = 1;
    cin>>t_c_;

     // BEGIN CODE HERE

    while(t_c_--){
        int n;
        cin >> n;
        int sum = 0;

        for(int i = 1; i <= n; i++){
            cin >> ar[i];
            sum += ar[i];
        }

        if(sum%n){
            cout<<"-1\n";
            continue;
        }

        for(int i = 2; i <= n; i++){
            if(ar[i]%i){
                cout<<"1 "<<i<<" "<<i - (ar[i]%i)<<'\n';
                ar[1] -= i - (ar[i]%i);
                ar[i] = (ar[i]/i + 1)*i;
            }
            cout<<i<<" 1 "<<ar[i]/i<<'\n';
        }

        for(int i = 2; i <= n; i++){
            cout<<"1 "<<i<<" "<<sum/n<<'\n';
        }

    }
    //getch();
}


#include<bits/stdc++.h>
//#include<conio.h>
using namespace std;    // instances like vi,stack,queue, cin ,cout OF STANDARD NAMESPACE (one predefined).

#define ff first
#define ss second
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define pb push_back
//  for counting setbits -> __builtin_popcountll(x)
// for counting zerobits -> __builtin_ctzll(x)

#define fastio ios_base::sync_with_stdio(false);        cin.tie(NULL); //(unties i/o buffer).
            // DON'T USE SCANF/PRINTF WITH IT (c/c++ -> seperates buffer).

// (first place constants class/struct, then functions (using them))

// ** Here can only DEFINE (variable initialise while defining) , CAN'T SET VALUE.
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2e5 + 5;
int ar[N] , ans[N];

int32_t main(){
    fastio

    #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
    #endif

     // ***** AC_chahiye EK BAR MEIN

    int t_c_ = 1;
    cin>>t_c_;

     // BEGIN CODE HERE

    while(t_c_--){
        int n;
        cin >> n;

        int sum = 0;
        for(int i = 1; i <= n; i++){
            cin >> ar[i];

            sum += ar[i];

            ans[i] = ans[i + n] = 0;
        }

        if(sum%n){
            cout<<"-1\n";
            continue;
        }

        int pos = 1;
        for(int i = 2 ; i <= n; i++){
            if(ar[i] > sum/n){
                if(i > ar[i]){
                    pos = 0;
                    break;
                }
                else{
                    ans[i] = (ar[i]-(sum/n) + i-1)/i;
                    ar[i] -= ans[i]*i;
                }

            }
            ans[i + n] = (sum/n - ar[i]);
        }

        if(!pos){
            cout<<"-1\n";
            continue;
        }

        cout<<2*n<<'\n';
        for(int i = 1; i <= 2*n; i++){
            if(i <= n)
                cout<<i<<" 1";
            else
                cout<<"1 "<<i-n;

            cout<<" "<<ans[i]<<'\n';
        }
    }
    //getch();
}


#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
struct ngoc
{
    int i,j,val;
};
ngoc res[300005];
void nhap()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
}
void xuli()
{
    int tong=0;
    for (int i=1;i<=n;i++)
    {
        tong=tong+a[i];
    }
    if (tong%n!=0)
    {
        cout<<-1<<"\n";
        return;
    }
    int tb=tong/n;
    int dem=0;
    for (int i=2;i<=n;i++)
    {
        int tmp=a[i]/i;
        if (tmp==0) continue;
        dem++;
        a[i]=a[i]-tmp*i;
        res[dem].i=i;
        res[dem].j=1;
        res[dem].val=tmp;
        a[1]=a[1]+tmp*i;
    }
    for (int i=2;i<=n;i++)
        if (a[i]>tb)
        {
            int tmp=tb+i;
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            if (a[1]<tmp-a[i])
            {
                cout<<-1<<"\n";
                return;
            }
            res[dem].val=tmp-a[i];
            a[1]-=tmp-a[i];
            dem++;
            res[dem].i=i;
            res[dem].j=1;
            res[dem].val=1;
            a[1]+=i;
        }
    for (int i=2;i<=n;i++)
        if (a[i]<tb)
        {
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            if (a[1]<tb-a[i])
            {
                cout<<-1<<"\n";
                return;
            }
            res[dem].val=tb-a[i];
            a[1]=a[1]-(tb-a[i]);
        }
    cout<<dem<<"\n";
    for (int i=1;i<=dem;i++)
    {
        cout<<res[i].i<<" "<<res[i].j<<" "<<res[i].val<<"\n";
    }
}
int main()
{
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    int T;
    cin>>T;
    while (T--)
    {
        nhap();
        xuli();
    }
}


#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
struct ngoc
{
    int i,j,val;
};
ngoc res[300005];
void nhap()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
}
void xuli()
{
    int tong=0;
    for (int i=1;i<=n;i++)
    {
        tong=tong+a[i];
    }
    if (tong%n!=0)
    {
        cout<<-1<<"\n";
        return;
    }
    int tb=tong/n;
    int dem=0;
    for (int i=2;i<=n;i++)
    {
        int tmp=a[i]/i;
        if (tmp==0) continue;
        dem++;
        a[i]=a[i]-tmp*i;
        res[dem].i=i;
        res[dem].j=1;
        res[dem].val=tmp;
        a[1]=a[1]+tmp*i;
    }
    for (int i=2;i<=n;i++)
        if (a[i]!=0)
        {
            int tmp=i-a[i];
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            res[dem].val=tmp;
            a[1]-=tmp;
            dem++;
            res[dem].i=i;
            res[dem].j=1;
            res[dem].val=1;
            a[1]=a[1]+i;
        }
    for (int i=2;i<=n;i++)
        {
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            res[dem].val=tb;
        }
    cout<<dem<<"\n";
    for (int i=1;i<=dem;i++)
    {
        cout<<res[i].i<<" "<<res[i].j<<" "<<res[i].val<<"\n";
    }
}
int main()
{
    int T;
    cin>>T;
    while (T--)
    {
        nhap();
        xuli();
    }
}


#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
struct ngoc
{
    int i,j,val;
};
ngoc res[300005];
void nhap()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
}
void xuli()
{
    int tong=0;
    for (int i=1;i<=n;i++)
    {
        tong=tong+a[i];
    }
    if (tong%n!=0)
    {
        cout<<-1<<"\n";
        return;
    }
    int tb=tong/n;
    int dem=0;
    for (int i=2;i<=n;i++)
        {
            int tmp=i-(a[i]%i);
            if (tmp==i) tmp=0;
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            res[dem].val=tmp;
            if (tmp==0) dem--;
            a[1]-=tmp;
            dem++;
            res[dem].i=i;
            res[dem].j=1;
            res[dem].val=(a[i]+tmp)/i;
            a[1]=a[1]+a[i]+tmp;
        }
    for (int i=2;i<=n;i++)
        {
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            res[dem].val=tb;
        }
    cout<<dem<<"\n";
    for (int i=1;i<=dem;i++)
    {
        cout<<res[i].i<<" "<<res[i].j<<" "<<res[i].val<<"\n";
    }
}
int main()
{

    int T;
    cin>>T;
    while (T--)
    {
        nhap();
        xuli();
    }
}


#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
struct ngoc
{
    int i,j,val;
};
ngoc res[300005];
void nhap()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
}
void xuli()
{
    int tong=0;
    for (int i=1;i<=n;i++)
    {
        tong=tong+a[i];
    }
    if (tong%n!=0)
    {
        cout<<-1<<"\n";
        return;
    }
    int tb=tong/n;
    int dem=0;
    for (int i=2;i<=n;i++)
        if (a[i]%i==0)
        {
            int tmp=i-(a[i]%i);
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            res[dem].val=tmp;
            a[1]-=tmp;
            dem++;
            res[dem].i=i;
            res[dem].j=1;
            res[dem].val=(a[i]+tmp)/i;
            a[1]=a[1]+a[i]+tmp;
        }
    for (int i=2;i<=n;i++)
        {
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            res[dem].val=tb;
        }
    cout<<dem<<"\n";
    for (int i=1;i<=dem;i++)
    {
        cout<<res[i].i<<" "<<res[i].j<<" "<<res[i].val<<"\n";
    }
}
int main()
{

    int T;
    cin>>T;
    while (T--)
    {
        nhap();
        xuli();
    }
}


#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
struct ngoc
{
    int i,j,val;
};
ngoc res[300005];
void nhap()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
}
void xuli()
{
    int tong=0;
    for (int i=1;i<=n;i++)
    {
        tong=tong+a[i];
    }
    if (tong%n!=0)
    {
        cout<<-1<<"\n";
        return;
    }
    int tb=tong/n;
    int dem=0;
    for (int i=2;i<=n;i++)
    {
        dem++;
        int tmp=a[i]/i;
        a[i]=a[i]-tmp*i;
        res[dem].i=i;
        res[dem].j=1;
        res[dem].val=tmp;
    }
    for (int i=2;i<=n;i++)
        if (a[i]>tb)
        {
            int tmp=tb+i;
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            res[dem].val=tmp-a[i];
            dem++;
            res[dem].i=i;
            res[dem].j=1;
            res[dem].val=1;
        }
    for (int i=2;i<=n;i++)
        if (a[i]<tb)
        {
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            res[dem].val=tb-a[i];
        }
    cout<<dem<<"\n";
    for (int i=1;i<=dem;i++)
    {
        cout<<res[i].i<<" "<<res[i].j<<" "<<res[i].val<<"\n";
    }
}
int main()
{
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    int T;
    cin>>T;
    while (T--)
    {
        nhap();
        xuli();
    }
}


#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
struct ngoc
{
    int i,j,val;
};
ngoc res[300005];
void nhap()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
}
void xuli()
{
    int tong=0;
    for (int i=1;i<=n;i++)
    {
        tong=tong+a[i];
    }
    if (tong%n!=0)
    {
        cout<<-1<<"\n";
        return;
    }
    int tb=tong/n;
    int dem=0;
    for (int i=2;i<=n;i++)
    {
        int tmp=a[i]/i;
        if (tmp==0) continue;
        dem++;
        a[i]=a[i]-tmp*i;
        res[dem].i=i;
        res[dem].j=1;
        res[dem].val=tmp;
    }
    for (int i=2;i<=n;i++)
        if (a[i]>tb)
        {
            int tmp=tb+i;
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            res[dem].val=tmp-a[i];
            dem++;
            res[dem].i=i;
            res[dem].j=1;
            res[dem].val=1;
        }
    for (int i=2;i<=n;i++)
        if (a[i]<tb)
        {
            dem++;
            res[dem].i=1;
            res[dem].j=i;
            res[dem].val=tb-a[i];
        }
    cout<<dem<<"\n";
    for (int i=1;i<=dem;i++)
    {
        cout<<res[i].i<<" "<<res[i].j<<" "<<res[i].val<<"\n";
    }
}
int main()
{
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    int T;
    cin>>T;
    while (T--)
    {
        nhap();
        xuli();
    }
}