#include<bits/stdc++.h>
using namespace std;
int N;

int main(){
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  
  map<int,int> L,R;
  int count=0;
  vector<int> ans;
  
  for(int i=0;i<N;i++){
    int lnum=a[i];
    int rnum=a[N-1-i];
    
    if( L[ lnum ] == R[ lnum ] ){
      count++;
    }
    L[ lnum ]++;
    if( L[ lnum ] == R[ lnum ] ){
      count--;
    }
    
    if( L[ rnum ] == R[ rnum ] ){
      count++;
    }
    R[ rnum ]++;
    if( L[ rnum ] == R[ rnum ] ){
      count--;
    }
    
    if( count == 0 ){
      ans.push_back(i+1);
    }
  }
  for(int i=0;i<(int)ans.size();i++){
    if(i)cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;
  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;
int N;

int main(){
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  
  map<int,int> L,R;
  int count=0;
  vector<int> ans;
  
  for(int i=0;i<N;i++){
    int lnum=a[i];
    int rnum=a[N-1-i];
    
    if( L[ lnum ] == R[ lnum ] ){
      count++;
    }
    L[ lnum ]++;
    if( L[ lnum ] == R[ lnum ] ){
      count--;
    }
    
    if( L[ rnum ] == R[ rnum ] ){
      count++;
    }
    R[ rnum ]++;
    if( L[ rnum ] == R[ rnum ] ){
      count--;
    }
    
    if( count == 0 ){
      ans.push_back(i+1);
    }
  }
  for(int i=0;i<(int)ans.size();i++){
    if(i)cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


```