import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; int[] ans = new int[n]; HashSet set = new HashSet<>(); ArrayList unmatch = new ArrayList<>(); for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); set.add(arr[i]); ans[i] = i; if (arr[i] == i) { unmatch.add(i); } } if (set.size() == 1 && unmatch.size() != 0) { System.out.println(-1); return; } for (int i = 0; i < unmatch.size() / 2; i++) { int tmp = ans[unmatch.get(i * 2)]; ans[unmatch.get(i * 2)] = ans[unmatch.get(i * 2 + 1)]; ans[unmatch.get(i * 2 + 1)] = tmp; } if (unmatch.size() % 2 == 1) { int x = unmatch.get(unmatch.size() - 1); for (int i = 0; i < n; i++) { if (arr[i] != ans[x]) { int tmp = ans[i]; ans[i] = ans[x]; ans[x] = tmp; break; } } } StringBuilder sb = new StringBuilder(); for (int x : ans) { sb.append(x).append("\n"); } System.out.print(sb); } }