#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	map<int, int> P;
	map<int, int> Q;
	bool flag = false;
	for (int i = 0; i < N; i++)
	{
		P[A[i]]++;
		Q[A[N - i - 1]]++;
		if (P == Q)
		{
			if (flag)cout << " ";
			cout << (i + 1);
			flag = true;
		}
	}
	cout << endl;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	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 "bits/stdc++.h"
using namespace std;
#define mod 1000000007
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	map<int, int> P;
	map<int, int> Q;
	bool flag = false;
	for (int i = 0; i < N; i++)
	{
		P[A[i]]++;
		Q[A[N - i - 1]]++;
		if (P == Q)
		{
			if (flag)cout << " ";
			cout << (i + 1);
			flag = true;
		}
	}
	cout << endl;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

```