#include <bits/stdc++.h>
#define rep(a,b,c) for(auto a = (b); a != (c); a++)
#define repD(a,b,c) for(auto a = (b); a != (c); a--)
#define repIn(a, b) for(auto& a : (b))
#define repIn2(a, b, c) for(auto& [a, b] : (c))
constexpr bool dbg = 1;
#define DEBUG if constexpr(dbg)
#define DC DEBUG std::cerr
#define eol std::endl
#define int long long
#define ld long double
#define pb push_back
#define rg ranges
using namespace std;
constexpr int inf = 1e9 + 7;
int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n;
cin >> n;
vector<int> v(n);
repIn(i, v) cin >> i;
vector<pair<int, int>> vp(n);
rep(i, 0, n) vp[i] = {v[i], i};
rg::sort(vp);
rg::reverse(vp);
int m;
cin >> m;
int s;
cin >> s;
int sumV = 0;
repIn(i, v) sumV += i;
vector<vector<int>> ans;
rep(_, 0, sumV / s) {
int il = s, ir = s;
while(il && vp[il - 1].first == vp[il].first) il--;
while(ir + 1 < n && vp[ir + 1].first == vp[ir].first) ir++;
vector<int> mv;
rep(i, 0, il) mv.pb(vp[i].second), vp[i].first--;
rep(i, 0, s - il) mv.pb(vp[ir - i].second), vp[ir - i].first--;
ans.pb(mv);
}
bool g = sumV % s == 0;
rep(i, 0, n) g = g && vp[i].first == 0;
cout << (!g ? -1 : (int)ans.size()) << '\n';
if(!g) return 0;
repIn(i, ans) {
cout << i.size() << ' ';
repIn(j, i) cout << j << ' ';
cout << '\n';
}
}