#include using namespace std; using ll = long long; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } template ostream& operator << (ostream& os, const vector& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n); cin >> a; map mp, mp2; int r = -1; for(int i = 0; i < n; i++){ mp[a[i]]++; if(mp[a[i]] == 1) r = i + 1; else break; } int l = n; for(int i = n - 1; i >= 0; i--){ mp2[a[i]]++; if(mp2[a[i]] == 1) l = i; else break; } vector ans; for(int i = max(1, l); i <= r && i <= n - 1; i++){ ans.push_back(i); } cout << ans.size() << '\n' << ans << '\n'; }