#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using db = double;
using vi = vector<int>;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define debug(x) cout << #x <<"	"<< x <<endl
const int inf = 0x3f3f3f3f;
const db eps = 1e-8;
const int mod = 1e9+7;
ll qpow(ll a, ll b){
    ll ret = 1;
    while(b){
        if(b&1)ret = ret*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return ret;
}
const int maxn = 1<<10;
int n;
int a[maxn], b[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin >> n;
	for(int i=1; i<=n; ++i){
		a[i] = (2*i)%n+1;
		b[i] = (2*i+1)%n+1;
	}
	for(int i=1; i<=n; ++i)cout << a[i] <<" " << b[i] <<"\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int32> p(n);
  REP(i,n)cin >> p[i],--p[i];
  queue<int32> que;
  vector<bool> used(n,false);
  REP(i,n-1){
    if(i < p[i] && p[i+1] < i+1)que.emplace(i);
  }
  vector<int32> ans;
  while(que.size()){
    int32 i = que.front();que.pop();
    if(!(i < p[i] && p[i+1] < i+1))continue;
    if(used[i]){
      ANS(-1);
      return 0;
    }
    ans.emplace_back(i);
    used[i] = true;
    swap(p[i],p[i+1]);
    if(i-1 >= 0 && i-1 < p[i-1] && p[i] < i)que.emplace(i-1);
    if(i+2 < n && i+1 < p[i+1] && p[i+2] < i+2)que.emplace(i+1);
  }
  REP(i,n){
    if(p[i] != i){
      ANS(-1);
      return 0;
    }
  }
  if(ans.size() != n-1){
    ANS(-1);
    return 0;
  }
  REP(i,n-1)ANS(ans[i]+1);
  return 0;
}