Niwango has N cards, numbered 1,2,\ldots,N. He will now arrange these cards in a row.

Niwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below. To help him, determine whether such a way exists. If the answer is yes, also find the lexicographically smallest such arrangement.

* To the immediate right of Card 1 (if any) is NOT Card a_1.
* To the immediate right of Card 2 (if any) is NOT Card a_2.
* \vdots
* To the immediate right of Card N (if any) is NOT Card a_N.

Constraints

* 2 \leq N \leq 10^{5}
* 1 \leq a_i \leq N
* a_i \neq i

Input

Input is given from Standard Input in the following format:


N
a_1 a_2 \ldots a_N


Output

If no arrangements satisfy the conditions, print `-1`. If such arrangements exist, print the lexicographically smallest such arrangement, in the following format:


b_1 b_2 \ldots b_N


Here, b_i represents the i-th card from the left.

Examples

Input

4
2 3 4 1


Output

1 3 2 4


Input

2
2 1


Output

-1


Input

13
2 3 4 5 6 7 8 9 10 11 12 13 12


Output

1 3 2 4 6 5 7 9 8 10 12 11 13
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

int a[100000];
int b[100000];

bool check(set <int> &s, int x) {
    int y, z;
    
    if (s.size() != 3) return true;
    
    s.erase(x);
    y = *s.begin();
    z = *s.rbegin();
    s.insert(x);
    
    if (a[y] == z && a[z] == y) return false;
    
    return true;
}

int main() {
    int n, i;
    vector <int> v;
    set <int> s;
    set <pair<int, int>> s2;
    set <int>::iterator it;
    
    scanf("%d", &n);
    
    if (n == 2) {
        puts("-1");
        
        return 0;
    }
    
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        
        a[i]--;
        b[a[i]]++;
    }
    
    for (i = 0; i < n; i++) s.insert(i);
    for (i = 0; i < n; i++) s2.insert(make_pair(b[i], i));
    
    for (i = 0; i < n; i++) {
        int x;
        
        if (s2.size() > 0 && s2.rbegin()->first == n - i - 1) {
            x = s2.rbegin()->second;
        } else {
            for (it = s.begin(); it != s.end(); it++) {
                if (i > 0 && a[v.back()] == *it) continue;
                if (!check(s, *it)) continue;
                x = *it;
                break;
            }
            
            if (it == s.end()) {
                puts("-1");
                
                return 0;
            }
        }
        
        v.push_back(x);
        s.erase(x);
        s2.erase(make_pair(b[x], x));
        s2.erase(make_pair(b[a[x]], a[x]));
        b[a[x]]--;
        if (b[a[x]] > 0 && s.count(a[x])) s2.insert(make_pair(b[a[x]], a[x]));
    }
    
    for (i = 0; i < n; i++) {
        if (i > 0) putchar(' ');
        printf("%d", v[i] + 1);
    }
    puts("");
    
    return 0;
}
