#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    map<int, int> mp1, mp2;
    rep(i, N-1){
        mp1[A[i]]++, mp2[A[N-i-1]]++;
        if(mp1.count(A[N-i-1]) && mp2.count(A[N-i-1])){
            mp1[A[N-i-1]]--, mp2[A[N-i-1]]--;
            if(mp1[A[N-i-1]] == 0) mp1.erase(A[N-i-1]);
            if(mp2[A[N-i-1]] == 0) mp2.erase(A[N-i-1]);
        }
        if(mp1.count(A[i]) && mp2.count(A[i])){
            mp1[A[i]]--, mp2[A[i]]--;
            if(mp1[A[i]] == 0) mp1.erase(A[i]);
            if(mp2[A[i]] == 0) mp2.erase(A[i]);
        }
        if(mp1.empty() && mp2.empty()) cout << i+1 << ' ';
    }
    cout << N << endl;
}

### Prompt

Please formulate 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;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    map<int, int> mp1, mp2;
    rep(i, N-1){
        mp1[A[i]]++, mp2[A[N-i-1]]++;
        if(mp1.count(A[N-i-1]) && mp2.count(A[N-i-1])){
            mp1[A[N-i-1]]--, mp2[A[N-i-1]]--;
            if(mp1[A[N-i-1]] == 0) mp1.erase(A[N-i-1]);
            if(mp2[A[N-i-1]] == 0) mp2.erase(A[N-i-1]);
        }
        if(mp1.count(A[i]) && mp2.count(A[i])){
            mp1[A[i]]--, mp2[A[i]]--;
            if(mp1[A[i]] == 0) mp1.erase(A[i]);
            if(mp2[A[i]] == 0) mp2.erase(A[i]);
        }
        if(mp1.empty() && mp2.empty()) cout << i+1 << ' ';
    }
    cout << N << endl;
}

```