#include using namespace std; int main(){ int n; cin >> n; vector a(n); for(int j = 0; j < n; j++)cin >> a[j]; map counts;//ある要素が何個含まれているかのカウント map loc;//要素のうち一番左のものの位置 vector l(0),r(0); for(int j = 0; j < n; j++){ counts[a[j]]++; if(counts[a[j]] == 1){ loc[a[j]] = j; } else if(counts[a[j]] == 2){ l.push_back(loc[a[j]]); r.push_back(j); } else{ //同じ要素が3つ含まれているなら条件を満たすjは存在しない cout << 0 << endl; cout << endl; return 0; } } int m = l.size(); int L = 0,R = n-1; for(int j = 0; j < m; j++){ L = max(L,l[j]); R = min(R,r[j]); } if(L > R){ cout << 0 << endl; cout << endl; return 0; } else{ cout << R - L << endl; for(int j = L; j < R; j++){ cout << j + 1 << " "; } cout << endl; return 0; } return 0; }