#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
int num[maxn], pos[maxn], used[maxn];
vector<vector<int> > rpl[maxn], ans;
int answer[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
    pos[num[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (used[num[i]]) continue;
    vector<int> tmp;
    tmp.push_back(num[i]);
    used[num[i]] = 1;
    if (used[i]) {
      rpl[tmp.size()].push_back(tmp);
      continue;
    }
    used[i] = 1;
    tmp.push_back(i);
    int t = pos[i];
    while (!used[t]) {
      used[t] = 1;
      tmp.push_back(t);
      t = pos[t];
    }
    rpl[tmp.size()].push_back(tmp);
  }
  for (int i = 1; i <= n; i++) {
    if ((i & 1) == 0 && rpl[i].size() & 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (i & 1) {
      for (int j = 0; j < rpl[i].size(); j++) {
        vector<int> tmp(rpl[i][j].size());
        for (int k = 0, t = 0; k < rpl[i][j].size();
             k++, t = (t + 2) % rpl[i][j].size()) {
          tmp[t] = rpl[i][j][k];
        }
        ans.push_back(tmp);
      }
    } else {
      for (int j = 0, t = 0; j < rpl[i].size(); j += 2) {
        vector<int> tmp;
        for (int k = 0; k < rpl[i][j].size(); k++) {
          tmp.push_back(rpl[i][j][k]), tmp.push_back(rpl[i][j + 1][k]);
        }
        ans.push_back(tmp);
      }
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    for (int j = 0; j < ans[i].size() - 1; j++) {
      answer[ans[i][j + 1]] = ans[i][j];
    }
    answer[ans[i][0]] = ans[i][ans[i].size() - 1];
  }
  for (int i = 1; i <= n; i++) printf("%d ", answer[i]);
  return 0;
}
