#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  int n; cin >>n;
  vector<int> a(n); rep(i, n) cin >>a.at(i);
  map<int,int> left, right;
  int res = 0;
  vector<int> k(n, -1);
  int lefts = 0, rights = 0;
  rep(i, n){
    int x = a[i], y = a[n-1-i];
    if (x != y){
      if (right[x] > 0){
        right[x]--;
        if (right[x] == 0) rights--;
      }else{
        left[x]++;
        if (left[x] == 1) lefts++;
      }
      if (left[y] > 0){
        left[y]--;
        if (left[y] == 0) lefts--;
      }else{
        right[y]++;
        if (right[y] == 1) rights++;
      }
    }
    if (lefts == 0 && rights == 0){
      k[res] = i+1; res++;
    }
  }
  rep(i, res){
    cout <<k[i];
    if (i < res-1) cout <<" ";
  }
  cout <<endl;
}


### Prompt

Please create a solution in CPP 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>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  int n; cin >>n;
  vector<int> a(n); rep(i, n) cin >>a.at(i);
  map<int,int> left, right;
  int res = 0;
  vector<int> k(n, -1);
  int lefts = 0, rights = 0;
  rep(i, n){
    int x = a[i], y = a[n-1-i];
    if (x != y){
      if (right[x] > 0){
        right[x]--;
        if (right[x] == 0) rights--;
      }else{
        left[x]++;
        if (left[x] == 1) lefts++;
      }
      if (left[y] > 0){
        left[y]--;
        if (left[y] == 0) lefts--;
      }else{
        right[y]++;
        if (right[y] == 1) rights++;
      }
    }
    if (lefts == 0 && rights == 0){
      k[res] = i+1; res++;
    }
  }
  rep(i, res){
    cout <<k[i];
    if (i < res-1) cout <<" ";
  }
  cout <<endl;
}


```