#include using namespace std; using ll = long long; using ld = long double; #ifdef LOCAL #include #else #define debug(...) void(0) #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin >> N; vector A(N); for(int i = 0; i < N; i++) cin >> A[i]; map MP1, MP2; for(int i = 0; i < N; i++) MP2[A[i]]++; int s1 = 0, s2 = 0; for(auto&&[a, b]: MP2) { if(b >= 2) { s2++; } } vector ans; for(int i = 0; i < N - 1; i++) { MP2[A[i]]--; MP1[A[i]]++; if(MP2[A[i]] == 1) s2--; if(MP1[A[i]] == 2) s1++; if(s1 == 0 && s2 == 0) { ans.push_back(i + 1); } } cout << int(ans.size()) << endl; for(auto&&a : ans) { cout << a << " "; }cout << endl; }