#include <bits/stdc++.h>
using namespace std;
void ptf (vector<int> &a){
cout << a.size() << " ";
sort(a.begin(), a.end());
for (int x : a)
cout << x << " ";
cout << "\n";
a.clear();
}
int32_t main (){
ios::sync_with_stdio(false); cin.tie(nullptr);
if (fopen("test.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
int n; cin >> n;
vector<pair<int, int>> a(n + 1);
for (int i = 1; i <= n; ++i){
cin >> a[i].first;
a[i].second = i;
}
sort(a.begin() + 1, a.end());
{
int i1 = a[n].first;
int i2 = i1 + a[i1].first;
if (i2 < n && a[i2].first <= n - i2){
vector<int> v;
for (int i = 1; i <= i1; ++i)
v.push_back(a[i].second);
ptf(v);
for (int i = i1 + 1; i <= i2; ++i)
v.push_back(a[i].second);
ptf(v);
return 0;
}
}
{
sort(a.begin() + 1, a.end(), greater<pair<int, int>>());
for (int i1 = 1; i1 + a[1].first <= n; ++i1){
int i2 = i1 + a[1].first;
if (i2 < n && n - i2 >= a[i1 + 1].first && a[i2 + 1].first <= i1){
vector<int> v;
for (int i = 1; i <= i1; ++i)
v.push_back(a[i].second);
ptf(v);
for (int i = i1 + 1; i <= i2; ++i)
v.push_back(a[i].second);
ptf(v);
return 0;
}
}
}
cout << -1;
}
// 4S 3D
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHB0ZiAodmVjdG9yPGludD4gJmEpewoJY291dCA8PCBhLnNpemUoKSA8PCAiICI7Cglzb3J0KGEuYmVnaW4oKSwgYS5lbmQoKSk7Cglmb3IgKGludCB4IDogYSkKCQljb3V0IDw8IHggPDwgIiAiOwoJY291dCA8PCAiXG4iOwoJYS5jbGVhcigpOwp9CgppbnQzMl90IG1haW4gKCl7Cglpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUobnVsbHB0cik7CglpZiAoZm9wZW4oInRlc3QuaW5wIiwgInIiKSl7CiAgICAgICA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