#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int N;
int A[100000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}

	map<int, int> m1, m2;
	set<int> same;
	vector<int> ans;
	for(int i = 0; i < N; i++){
		set<int> s;
		m1[A[i]]++;
		m2[A[N - 1 - i]]++;
		s.insert(A[i]);
		s.insert(A[N - 1 - i]);
		for(auto a : s){
			if(same.count(a)) same.erase(a);
		}
		for(auto a : s){
			if(m1.count(a) && m2.count(a) && m1[a] == m2[a]){
				same.insert(a);
			}
		}
		if(same.size() == m1.size()){
			ans.push_back(i + 1);
		}
	}

	for(int i = 0; i < ans.size(); i++){
		cout << ans[i];
		if(i != ans.size() - 1) cout << " ";
	}
	cout << endl;
}


### Prompt

Generate a CPP solution to 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;

int N;
int A[100000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}

	map<int, int> m1, m2;
	set<int> same;
	vector<int> ans;
	for(int i = 0; i < N; i++){
		set<int> s;
		m1[A[i]]++;
		m2[A[N - 1 - i]]++;
		s.insert(A[i]);
		s.insert(A[N - 1 - i]);
		for(auto a : s){
			if(same.count(a)) same.erase(a);
		}
		for(auto a : s){
			if(m1.count(a) && m2.count(a) && m1[a] == m2[a]){
				same.insert(a);
			}
		}
		if(same.size() == m1.size()){
			ans.push_back(i + 1);
		}
	}

	for(int i = 0; i < ans.size(); i++){
		cout << ans[i];
		if(i != ans.size() - 1) cout << " ";
	}
	cout << endl;
}


```