#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto start=chrono::system_clock::now();
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> p(n);
    rep(i,n) p[i]=i+1;
    map<ll,vector<ll>> mp;
    do{
        auto now=chrono::system_clock::now();
        int ms=chrono::duration_cast<chrono::milliseconds>(now-start).count();
        if(1980<ms) break;
        ll x=0;
        rep(i,n) x^=(p[i]+a[i]);
        if(!mp[x].empty()){
            for(auto i:mp[x]) cout << i << ' ';
            cout << '\n';
            for(auto i:p) cout << i << ' ';
            cout << '\n';
            return 0;
        }
        mp[x]=p;
    }while(next_permutation(all(p)));
    cout << "-1\n";
}