#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-5;
const int P = 1e9 + 7;
const int MX = 1e6 + 5;
int n;
int w[MX];
struct Nod {
  vector<int> w;
  bool operator<(const Nod a) const { return w.size() < a.w.size(); }
} Q[MX];
int num[MX];
int anss[MX];
bool vis[MX];
int main() {
  while (cin >> n) {
    for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
    int cnt = 0;
    for (int i = 1; i <= n; i++) vis[i] = 0, num[i] = 0;
    for (int i = 1; i <= n; i++)
      if (vis[i] == 0) {
        Q[cnt].w.push_back(i);
        int now = w[i];
        vis[i] = 1;
        while (now != i) {
          Q[cnt].w.push_back(now);
          vis[now] = 1;
          now = w[now];
        }
        num[Q[cnt].w.size()]++;
        cnt++;
      }
    int flag = 0;
    for (int i = 1; i <= n; i++)
      if ((i % 2 == 0) && (num[i] & 1)) flag = 1;
    if (flag) {
      puts("-1");
    } else {
      sort(Q, Q + cnt);
      vector<vector<int>> ans;
      for (int i = 0; i < cnt;) {
        vector<int> tmp;
        if (Q[i].w.size() & 1) {
          for (int j = 0; j < Q[i].w.size(); j++)
            if (j & 1) {
              tmp.push_back(Q[i].w[(j + 1) / 2 + (Q[i].w.size() / 2)]);
            } else {
              tmp.push_back(Q[i].w[j / 2]);
            }
          i++;
        } else {
          for (int j = 0; j < Q[i].w.size(); j++) {
            tmp.push_back(Q[i].w[j]);
            tmp.push_back(Q[i + 1].w[j]);
          }
          i += 2;
        }
        ans.push_back(tmp);
      }
      for (int i = 0; i < ans.size(); i++) {
        for (int j = 0; j < ans[i].size(); j++) {
          int v = (j + 1) % ans[i].size();
          anss[ans[i][j]] = ans[i][v];
        }
      }
      for (int i = 1; i <= n; i++) printf("%d%c", anss[i], i == n ? '\n' : ' ');
    }
    for (int i = 0; i < cnt; i++) Q[i].w.clear();
  }
  return 0;
}
