#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N,i;scanf("%d",&N);
  int a[N];
  map<int,int> ml,mr;
  for(i=0;i<N;i++) scanf("%d",&a[i]);
  int ng = 0;vector<int> ans;
  for(i=0;i<N;i++){
    ml[a[i]]++;
    if(ml[a[i]] == mr[a[i]]) ng--;
    else if(ml[a[i]]-1 == mr[a[i]]) ng++;
    mr[a[N-i-1]]++;
    if(ml[a[N-i-1]] == mr[a[N-i-1]]) ng--;
    else if(ml[a[N-i-1]] == mr[a[N-i-1]]-1) ng++;
    if(ng == 0) ans.push_back(i+1);
  }
  for(i=0;i<ans.size()-1;i++) printf("%d ",ans[i]);
  printf("%d\n",ans.back());
}

### Prompt

Your challenge is to write 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;
typedef long long ll;
int main(){
  int N,i;scanf("%d",&N);
  int a[N];
  map<int,int> ml,mr;
  for(i=0;i<N;i++) scanf("%d",&a[i]);
  int ng = 0;vector<int> ans;
  for(i=0;i<N;i++){
    ml[a[i]]++;
    if(ml[a[i]] == mr[a[i]]) ng--;
    else if(ml[a[i]]-1 == mr[a[i]]) ng++;
    mr[a[N-i-1]]++;
    if(ml[a[N-i-1]] == mr[a[N-i-1]]) ng--;
    else if(ml[a[N-i-1]] == mr[a[N-i-1]]-1) ng++;
    if(ng == 0) ans.push_back(i+1);
  }
  for(i=0;i<ans.size()-1;i++) printf("%d ",ans[i]);
  printf("%d\n",ans.back());
}

```