#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<int> a(n);
  set<int> st;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    st.insert(a[i]);
  }

  map<int, int> zip;
  int val = 0;
  for (auto x : st) {
    zip[x] = val;
    val++;
  }

  for (int i = 0; i < n; i++) {
    a[i] = zip[a[i]];
  }

  int minus = 0;
  int plus = 0;
  vector<int> ans;
  vector<int> cnt(n + 2, 0);

  for (int k = 0; k < n; k++) {
    cnt[a[k]]++;
    if (cnt[a[k]] == 0) {
      minus--;
    } else if (cnt[a[k]] == 1) {
      plus++;
    }

    cnt[a[n - k - 1]]--;
    if (cnt[a[n - k - 1]] == 0) {
      plus--;
    } else if (cnt[a[n - k - 1]] == -1) {
      minus++;
    }

    if (plus == 0 and minus == 0) {
      ans.push_back(k + 1);
    }
  }

  for (size_t i = 0; i < ans.size(); i++) {
    if (i + 1 == ans.size()) cout << ans[i] << endl;
    else cout << ans[i] << " ";
  }
  
  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 <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<int> a(n);
  set<int> st;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    st.insert(a[i]);
  }

  map<int, int> zip;
  int val = 0;
  for (auto x : st) {
    zip[x] = val;
    val++;
  }

  for (int i = 0; i < n; i++) {
    a[i] = zip[a[i]];
  }

  int minus = 0;
  int plus = 0;
  vector<int> ans;
  vector<int> cnt(n + 2, 0);

  for (int k = 0; k < n; k++) {
    cnt[a[k]]++;
    if (cnt[a[k]] == 0) {
      minus--;
    } else if (cnt[a[k]] == 1) {
      plus++;
    }

    cnt[a[n - k - 1]]--;
    if (cnt[a[n - k - 1]] == 0) {
      plus--;
    } else if (cnt[a[n - k - 1]] == -1) {
      minus++;
    }

    if (plus == 0 and minus == 0) {
      ans.push_back(k + 1);
    }
  }

  for (size_t i = 0; i < ans.size(); i++) {
    if (i + 1 == ans.size()) cout << ans[i] << endl;
    else cout << ans[i] << " ";
  }
  
  return 0;
}


```