#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pr;
const double pi=acos(-1);
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define Rep(i,u) for(int i=head[u];i;i=Next[i])
#define clr(a) memset(a,0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define pq priority_queue
#define pqb priority_queue <int, vector<int>, less<int> >
#define pqs priority_queue <int, vector<int>, greater<int> >
#define vec vector
ld eps=1e-9;
ll pp=1000000007;
ll mo(ll a,ll pp){if(a>=0 && a<pp)return a;a%=pp;if(a<0)a+=pp;return a;}
ll powmod(ll a,ll b,ll pp){ll ans=1;for(;b;b>>=1,a=mo(a*a,pp))if(b&1)ans=mo(ans*a,pp);return ans;}
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
//void add(int x,int y,int z){ v[++e]=y; next[e]=head[x]; head[x]=e; cost[e]=z; }
int dx[5]={0,-1,1,0,0},dy[5]={0,0,0,-1,1};
ll read(){ ll ans=0; char last=‘ ‘,ch=getchar();
while(ch<‘0‘ || ch>‘9‘)last=ch,ch=getchar();
while(ch>=‘0‘ && ch<=‘9‘)ans=ans*10+ch-‘0‘,ch=getchar();
if(last==‘-‘)ans=-ans; return ans;
}
#define N 100005
map<pr,int> Map;
int B[N],a[N],Left[N],n,b[N],Right[N],Len;
void init()
{
n=read();
rep(i,1,n)
a[i]=read();
}
void LIS()
{
B[1]=a[1];int len=1;Left[1]=1;
for(int i=2;i<=n;i++)
{
if(a[i]>B[len]) B[++len]=a[i];
int pos=lower_bound(B+1,B+1+len,a[i])-B;
B[pos]=a[i];
Left[i]=pos;
}
Len=len;
}
void RE_LIS()
{
memset(B,0,sizeof(B));
for(int i=1;i<=n;i++) b[i]=a[i];
for(int i=1;i<=n;i++) a[i]=-b[n-i+1];
B[1]=a[1];int len=1;Right[n]=1;
for(int i=2;i<=n;i++)
{
if(a[i]>B[len]) B[++len]=a[i];
int pos=lower_bound(B+1,B+1+len,a[i])-B;
B[pos]=a[i];
Right[n-i+1]=pos;
}
}
void Debug()
{
for(int i=1;i<=n;i++)
cout<<Left[i]<<‘ ‘<<Right[i]<<endl;
}
int main()
{
init();
LIS();
RE_LIS();
//Debug();
cout<<Len<<endl;
for(int i=1;i<=n;i++)
if(Left[i]+Right[i]-1==Len)
{
Map[mp(Left[i],Right[i])]++;
}
for(int i=1;i<=n;i++)
if(Map[mp(Left[i],Right[i])]==1) printf("%d ",i);
}