#include using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair; using tll=tuple; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++) #define all(v) v.begin(),v.end() #define len(v) ((ll)v.size()) template inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template inline bool chmax(T &a,T b){ if(a struct segment_tree{ int n; vector v; segment_tree(int n_):n(n_),v(n*2,e){} segment_tree(vector a):n((int)a.size()),v(n*2,e){ for(int i=0;i>=1; v[i]=op(v[i<<1],v[i<<1|1]); } } T get(int i){ i+=n; return v[i]; } T fold(int l,int r){ //[l,r) assert(0<=l&&l<=n); assert(0<=r&&r<=n); assert(l<=r); T ret_l=e,ret_r=e; l+=n; r+=n; for(;l>=1,r>>=1){ if(l&1) ret_l=op(ret_l,v[l++]); if(r&1) ret_r=op(v[--r],ret_r); } return op(ret_l,ret_r); } }; template vector compress(vector &x){ vector unique_v=x; int n=x.size(); sort(all(unique_v)); unique_v.erase(unique(all(unique_v)),unique_v.end()); for(int i=0;i> n; vector a(n); rep(i,n) cin >> a[i]; compress(a); segment_tree seg(n),seg2(n); rep(i,n){ ll x=seg.get(a[i]); seg.update(a[i],x+1); } vector ans; rep(i,n-1){ ll x=seg.get(a[i]); seg.update(a[i],x-1); ll y=seg2.get(a[i]); seg2.update(a[i],y+1); if(seg.fold(0,n)<=1&&seg2.fold(0,n)<=1) ans.push_back(i); } cout << len(ans) << '\n'; for(auto i:ans) cout << i+1 << ' '; cout << '\n'; }