
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
int A[123456];
int B[123456];
map<int, int>P, Q;
int cnt;

int main(void)
{
	cin >> N;
	vector<int>vec;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		B[N - 1 - i] = A[i];
	}
	for (int i = 0; i < N; ++i) {
		if (P[A[i]] != Q[A[i]]) {
			cnt--;
		}
		if (A[i] != B[i] && P[B[i]] != Q[B[i]]) {
			cnt--;
		}
		P[A[i]]++;
		Q[B[i]]++;
		if (P[A[i]] != Q[A[i]]) {
			cnt++;
		}
		if (A[i] != B[i] && P[B[i]] != Q[B[i]]) {
			cnt++;
		}
		if (cnt == 0) {
			vec.push_back(i + 1);
		}
	}
	for (int i = 0; i < vec.size(); ++i) {
		cout << vec[i];
		if (i + 1 != vec.size()) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}


### Prompt

Please provide a cpp coded solution to the problem described below:

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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
int A[123456];
int B[123456];
map<int, int>P, Q;
int cnt;

int main(void)
{
	cin >> N;
	vector<int>vec;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		B[N - 1 - i] = A[i];
	}
	for (int i = 0; i < N; ++i) {
		if (P[A[i]] != Q[A[i]]) {
			cnt--;
		}
		if (A[i] != B[i] && P[B[i]] != Q[B[i]]) {
			cnt--;
		}
		P[A[i]]++;
		Q[B[i]]++;
		if (P[A[i]] != Q[A[i]]) {
			cnt++;
		}
		if (A[i] != B[i] && P[B[i]] != Q[B[i]]) {
			cnt++;
		}
		if (cnt == 0) {
			vec.push_back(i + 1);
		}
	}
	for (int i = 0; i < vec.size(); ++i) {
		cout << vec[i];
		if (i + 1 != vec.size()) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}


```