#include<iostream>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];

    /*
    vector<int> ans;
    map<int,int> x, y;
    int ng = 0;
    for(int i = 0; i < n; i++){
        int j = n-1-i;
        if(x[a[i]]==y[a[i]])  ng++;
        x[a[i]]++;
        if(x[a[i]] == y[a[i]])  ng--;
        if(x[a[j]]==y[a[j]])  ng++;
        y[a[j]]++;
        if(x[a[j]] == y[a[j]])  ng--;
        if(ng == 0) ans.push_back(i+1);
    }
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << " \n"[i+1==ans.size()];
    */

    // editorial
    vector<int> ans;
    priority_queue<int> x, y;
    for(int i = 0; i < n; i++){
        int j = n-1-i;
        x.push(a[i]);
        y.push(a[j]);
        while(x.size() && x.top()==y.top())   x.pop(), y.pop();
        if(x.size() == 0)   ans.push_back(i+1);
    }
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << " \n"[i+1==ans.size()];
    return 0;
}

### Prompt

In cpp, your task is to solve the following problem:

problem

Given a sequence $ a_i $ of length $ N $. Output all integers $ K (1 \ le K \ le N) $ that satisfy the following conditions.

Condition: Well sorted $ a_1, \ cdots, a_K $ matches $ a_ {N-K + 1}, \ cdots, a_N $.





Example

Input

8
5 2 4 9 4 9 2 5


Output

1 2 4 6 7 8

### Response

```cpp
#include<iostream>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];

    /*
    vector<int> ans;
    map<int,int> x, y;
    int ng = 0;
    for(int i = 0; i < n; i++){
        int j = n-1-i;
        if(x[a[i]]==y[a[i]])  ng++;
        x[a[i]]++;
        if(x[a[i]] == y[a[i]])  ng--;
        if(x[a[j]]==y[a[j]])  ng++;
        y[a[j]]++;
        if(x[a[j]] == y[a[j]])  ng--;
        if(ng == 0) ans.push_back(i+1);
    }
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << " \n"[i+1==ans.size()];
    */

    // editorial
    vector<int> ans;
    priority_queue<int> x, y;
    for(int i = 0; i < n; i++){
        int j = n-1-i;
        x.push(a[i]);
        y.push(a[j]);
        while(x.size() && x.top()==y.top())   x.pop(), y.pop();
        if(x.size() == 0)   ans.push_back(i+1);
    }
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << " \n"[i+1==ans.size()];
    return 0;
}

```