#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
int n;
int d[4100][4100];
vector<int> ind[31];
int rev[405], ans[405], sub[405];
vector<int> v[3];
int main() {
//freopen("input.txt", "r", stdin);
scanf("%d", &n);
int tot = 0;
REP(i, n) {
int x;
scanf("%d", &x);
sub[i] = x;
tot += x;
ind[x].pb(i);
}
memset(d, -1, sizeof d);
d[0][0] = 0;
int sum = 1;
for (int i = 1; i <= 30; ++i) {
int sz = (int)ind[i].size();
sum = min(4100, sum + i * sz);
memset(rev, -1, sizeof rev);
REP(j, ind[i].size()) rev[ind[i][j]] = j;
REP(x, sum) REP(y, sum) if (d[x][y] != -1) {
int z = rev[d[x][y] >> 1] + 1;
if (z == sz) continue;
if (x + i < 4100 && (d[x + i][y] == -1 || rev[d[x + i][y] >> 1] > z)) {
d[x + i][y] = ind[i][z] << 1;
}
if (y + i < 4100 && (d[x][y + i] == -1 || rev[d[x][y + i] >> 1] > z)) {
d[x][y + i] = 1 | (ind[i][z] << 1);
}
}
}
int bi, bj, best;
bi = bj = -1;
best = 12341234;
REP(i, 4100) REP(j, 4100) if (d[i][j] != -1) {
int k = tot - i - j;
int mn = min(min(i, j), k);
int mx = max(max(i, j), k);
if (mx - mn < best) {
best = mx - mn;
bi = i;
bj = j;
}
}
REP(i, n) ans[i] = 2;
for (int i = bi, j = bj; i || j; ) {
int q = d[i][j] >> 1;
int w = d[i][j] & 1;
ans[q] = w;
if (w) j -= sub[q];
else i -= sub[q];
}
REP(i, n) v[ans[i]].pb(i + 1);
printf("%d\n", best);
REP(i, 3) {
printf("%d", (int)v[i].size());
for (int x : v[i]) printf(" %d", x);
printf("\n");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBSRVAoaSwgbikgZm9yIChpbnQgaSA9IDA7IGkgPCAoaW50KShuKTsgKytpKQp0eXBlZGVmIGxvbmcgbG9uZyBMTDsKdHlwZWRlZiBwYWlyPGludCwgaW50PiBQSUk7CgppbnQgbjsKaW50IGRbNDEwMF1bNDEwMF07CnZlY3RvcjxpbnQ+IGluZFszMV07CmludCByZXZbNDA1XSwgYW5zWzQwNV0sIHN1Yls0MDVdOwp2ZWN0b3I8aW50PiB2WzNdOwoKaW50IG1haW4oKSB7CiAgICAvL2ZyZW9wZW4oImlucHV0LnR4dCIsICJyIiwgc3RkaW4pOwogICAgc2NhbmYoIiVkIiwgJm4pOwogICAgaW50IHRvdCA9IDA7CiAgICBSRVAoaSwgbikgewogICAgICAgIGludCB4OwogICAgICAgIHNjYW5mKCIlZCIsICZ4KTsKICAgICAgICBzdWJbaV0gPSB4OwogICAgICAgIHRvdCArPSB4OwogICAgICAgIGluZFt4XS5wYihpKTsKICAgIH0KICAgIG1lbXNldChkLCAtMSwgc2l6ZW9mIGQpOwogICAgZFswXVswXSA9IDA7CiAgICBpbnQgc3VtID0gMTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IDMwOyArK2kpIHsKICAgICAgICBpbnQgc3ogPSAoaW50KWluZFtpXS5zaXplKCk7CiAgICAgICAgc3VtID0gbWluKDQxMDAsIHN1bSArIGkgKiBzeik7CiAgICAgICAgbWVtc2V0KHJldiwgLTEsIHNpemVvZiByZXYpOwogICAgICAgIFJFUChqLCBpbmRbaV0uc2l6ZSgpKSByZXZbaW5kW2ldW2pdXSA9IGo7CiAgICAgICAgUkVQKHgsIHN1bSkgUkVQKHksIHN1bSkgaWYgKGRbeF1beV0gIT0gLTEpIHsKICAgICAgICAgICAgaW50IHogPSByZXZbZFt4XVt5XSA+PiAxXSArIDE7CiAgICAgICAgICAgIGlmICh6ID09IHN6KSBjb250aW51ZTsKICAgICAgICAgICAgaWYgKHggKyBpIDwgNDEwMCAmJiAoZFt4ICsgaV1beV0gPT0gLTEgfHwgcmV2W2RbeCArIGldW3ldID4+IDFdID4geikpIHsKICAgICAgICAgICAgICAgIGRbeCArIGldW3ldID0gaW5kW2ldW3pdIDw8IDE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHkgKyBpIDwgNDEwMCAmJiAoZFt4XVt5ICsgaV0gPT0gLTEgfHwgcmV2W2RbeF1beSArIGldID4+IDFdID4geikpIHsKICAgICAgICAgICAgICAgIGRbeF1beSArIGldID0gMSB8IChpbmRbaV1bel0gPDwgMSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBpbnQgYmksIGJqLCBiZXN0OwogICAgYmkgPSBiaiA9IC0xOwogICAgYmVzdCA9IDEyMzQxMjM0OwogICAgUkVQKGksIDQxMDApIFJFUChqLCA0MTAwKSBpZiAoZFtpXVtqXSAhPSAtMSkgewogICAgICAgIGludCBrID0gdG90IC0gaSAtIGo7CiAgICAgICAgaW50IG1uID0gbWluKG1pbihpLCBqKSwgayk7CiAgICAgICAgaW50IG14ID0gbWF4KG1heChpLCBqKSwgayk7CiAgICAgICAgaWYgKG14IC0gbW4gPCBiZXN0KSB7CiAgICAgICAgICAgIGJlc3QgPSBteCAtIG1uOwogICAgICAgICAgICBiaSA9IGk7CiAgICAgICAgICAgIGJqID0gajsKICAgICAgICB9CiAgICB9CiAgICBSRVAoaSwgbikgYW5zW2ldID0gMjsKICAgIGZvciAoaW50IGkgPSBiaSwgaiA9IGJqOyBpIHx8IGo7ICkgewogICAgICAgIGludCBxID0gZFtpXVtqXSA+PiAxOwogICAgICAgIGludCB3ID0gZFtpXVtqXSAmIDE7CiAgICAgICAgYW5zW3FdID0gdzsKICAgICAgICBpZiAodykgaiAtPSBzdWJbcV07CiAgICAgICAgZWxzZSBpIC09IHN1YltxXTsKICAgIH0KICAgIFJFUChpLCBuKSB2W2Fuc1tpXV0ucGIoaSArIDEpOwogICAgcHJpbnRmKCIlZFxuIiwgYmVzdCk7CiAgICBSRVAoaSwgMykgewogICAgICAgIHByaW50ZigiJWQiLCAoaW50KXZbaV0uc2l6ZSgpKTsKICAgICAgICBmb3IgKGludCB4IDogdltpXSkgcHJpbnRmKCIgJWQiLCB4KTsKICAgICAgICBwcmludGYoIlxuIik7CiAgICB9CiAgICByZXR1cm4gMDsKfQo=