#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) void solve() { ll n, cnt = 0; cin >> n; map mpl, mpr; vector a(n); rep(i, n) { cin >> a[i]; if (++mpr[a[i]] == 2) cnt++; } vector ans; rep(i, n - 1) { if (--mpr[a[i]] == 1) cnt--; if (++mpl[a[i]] == 2) break; if (cnt == 0) ans.push_back(i + 1); } cout << ans.size() << '\n'; rep(i, ans.size()) cout << (i ? " " : "") << ans[i]; cout << '\n'; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; for (int t = 0; t < T; t++) { solve(); } return 0; }