import java.util.Scanner; public class Main_yukicoder241 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; boolean flag = true; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); if (i > 0 && a[i - 1] != a[i]) { flag = false; } } if (flag && a[0] < n) { System.out.println(-1); } else { int[] ret = new int[n]; for (int i = 0; i < n; i++) { ret[i] = i; } for (; true;) { for (int i = 0; i < n; i++) { int r = i + (int)(Math.random() * (n - i)); int tmp = ret[i]; ret[i] = ret[r]; ret[r] = tmp; } boolean check = true; for (int i = 0; i < n; i++) { if (ret[i] == a[i]) { check = false; break; } } if (check) { break; } } for (int i = 0; i < n; i++) { System.out.println(ret[i]); } } sc.close(); } }