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

int main() {
  int n;
  cin >> n;

  vector<int> a(n);
  for (auto &i : a) cin >> i;

  vector<int> zip = a;
  sort(zip.begin(), zip.end());
  zip.erase(unique(zip.begin(), zip.end()), zip.end());

  for (int i = 0; i < n; ++i) {
    a[i] = lower_bound(zip.begin(), zip.end(), a[i]) - zip.begin();
  }

  vector<int> ans;
  map<int, int> m;
  for (int k = 0; k < n; ++k) {
    m[a[k]]++;
    m[a[n - k - 1]]--;

    if (!m[a[k]]) m.erase(a[k]);
    if (!m[a[n - k - 1]]) m.erase(a[n - k - 1]);

    if (m.size() == 0) ans.push_back(k + 1);
  }

  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << (i + 1 == ans.size() ? "\n" : " ");
  }
}


### Prompt

Construct a Cpp code solution to the problem outlined:

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 main() {
  int n;
  cin >> n;

  vector<int> a(n);
  for (auto &i : a) cin >> i;

  vector<int> zip = a;
  sort(zip.begin(), zip.end());
  zip.erase(unique(zip.begin(), zip.end()), zip.end());

  for (int i = 0; i < n; ++i) {
    a[i] = lower_bound(zip.begin(), zip.end(), a[i]) - zip.begin();
  }

  vector<int> ans;
  map<int, int> m;
  for (int k = 0; k < n; ++k) {
    m[a[k]]++;
    m[a[n - k - 1]]--;

    if (!m[a[k]]) m.erase(a[k]);
    if (!m[a[n - k - 1]]) m.erase(a[n - k - 1]);

    if (m.size() == 0) ans.push_back(k + 1);
  }

  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << (i + 1 == ans.size() ? "\n" : " ");
  }
}


```