#include <bits/stdc++.h>
using namespace std;
void solve();
const long long N = 1e6 + 5;
long long nxt[N], q[N], tmp[N], tmp2[N], id[N];
bool vis[N];
char IN[1000000], *SS = IN, *TT = IN;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) cin >> nxt[i];
  for (long long s = 1; s <= n; ++s)
    if (!vis[s]) {
      long long cnt = 0, x = s;
      do {
        tmp[++cnt] = x, vis[x] = 1, x = nxt[x];
      } while (x != s);
      if (cnt & 1) {
        for (long long i = 1, now = 0; i <= cnt;
             ++i, (now += 2) >= cnt && (now -= cnt))
          tmp2[now] = tmp[i];
        for (long long i = 0; i < cnt; ++i) q[tmp2[i]] = tmp2[i + 1];
        q[tmp2[cnt - 1]] = tmp2[0];
      } else {
        if (!id[cnt])
          id[cnt] = s;
        else {
          long long y = id[cnt], x = y, t = 0;
          do {
            tmp2[++t] = x, x = nxt[x];
          } while (x != y);
          for (long long t1 = 1, t2 = 1, las = tmp[1], i = t << 1; i; --i)
            las = q[las] = i & 1 ? tmp[++t1] : tmp2[t2++];
          q[tmp2[t]] = tmp[1], id[t] = 0;
        }
      }
    }
  for (long long i = 2; i <= n; i += 2)
    if (id[i]) return cout << "-1", 0;
  for (long long i = 1; i <= n; ++i) cout << q[i] << " ";
}
