#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  vector<int> ans;
  map<int,int> mp;
  deque<int> yet;
  rep(i,n) {
    int r = n-1-i;
    ++mp[a[r]];
    yet.push_back(a[i]);
    while( !yet.empty() ) {
      if( mp[yet.front()] ) {
	mp[yet.front()]--;
	yet.pop_front();
      } else break;
    }
    if( yet.empty() ) {
      ans.push_back(i);
    }
  }
  /*
  if( n % 2 == 1 ) {
    if( ans.size() && ans.back() == (int)(n / 2)-1 ) {
      ans.push_back(n/2);
    }
  }
  vector<int> b;
  rep(i,(int)ans.size())  {
    b.push_back(i);
    b.push_back(n-1-i);
  }
  sort(ALL(b));
  b.erase(unique(ALL(b)),b.end());
  */
  vector<int> b = ans;
  rep(i,(int)b.size()) {
    if( i ) printf(" ");
    cout << b[i]+1;
  } puts("");
  compute();
  return 0;
}


### Prompt

Develop a solution in CPP 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>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  vector<int> ans;
  map<int,int> mp;
  deque<int> yet;
  rep(i,n) {
    int r = n-1-i;
    ++mp[a[r]];
    yet.push_back(a[i]);
    while( !yet.empty() ) {
      if( mp[yet.front()] ) {
	mp[yet.front()]--;
	yet.pop_front();
      } else break;
    }
    if( yet.empty() ) {
      ans.push_back(i);
    }
  }
  /*
  if( n % 2 == 1 ) {
    if( ans.size() && ans.back() == (int)(n / 2)-1 ) {
      ans.push_back(n/2);
    }
  }
  vector<int> b;
  rep(i,(int)ans.size())  {
    b.push_back(i);
    b.push_back(n-1-i);
  }
  sort(ALL(b));
  b.erase(unique(ALL(b)),b.end());
  */
  vector<int> b = ans;
  rep(i,(int)b.size()) {
    if( i ) printf(" ");
    cout << b[i]+1;
  } puts("");
  compute();
  return 0;
}


```