//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+100,block=1200;
int n,m,k,a[N],b[N*2],w,t[N*2];
int cnt[110][N*2],f[110][N],l;
struct node
{
	int op,x,y;
}q[N];
inline int lowbit(int x){return x&(-x);}
inline void change(int id,int x,int v)
{
	while (x>0)
	{
		f[id][x]+=v;
		x-=lowbit(x);
	}
}
inline int query(int id,int x)
{
	int ans=0;
	while (x<=m)
	{
		ans+=f[id][x];
		x+=lowbit(x);
	}
	return ans;
}
inline int read()
{
	int f=1,x=0;char s=getchar();
	while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
	while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
	return x*f;
}
int main()
{
	m=read();
	for (int i=1;i<=m;i++) a[i]=b[++w]=read();
	k=read();
	for (int i=1;i<=k;i++)
	{
		q[i].op=2-read(),q[i].x=read(),q[i].y=read();
		if (q[i].op==1) swap(q[i].x,q[i].y);
		if (q[i].op==1) b[++w]=q[i].y;
	}
	sort(b+1,b+1+w);
	w=unique(b+1,b+1+w)-b-1;
	for (int i=1;i<=m;i++) a[i]=lower_bound(b+1,b+w+1,a[i])-b;
	for (int i=1;i<=k;i++) if (q[i].op==1) q[i].y=lower_bound(b+1,b+w+1,q[i].y)-b;
	w=(m-1)/block+1;
	for (int i=1;i<=w;i++)
	{
		memcpy(f[i],f[i-1],sizeof(f[i]));
		memcpy(cnt[i],cnt[i-1],sizeof(cnt[i]));
		for (int j=(i-1)*block+1;j<=min(m,i*block);j++)
		{
			change(i,cnt[i][a[j]],-1);
			cnt[i][a[j]]++;
			change(i,cnt[i][a[j]],1);
		}
	}
	for (int i=1;i<=k;i++)
	{
		if (q[i].op==0)
		{
			if (q[i].x==1)
			{
				printf("%d\n",b[a[q[i].y]]);
				continue;
			}
			int id=(q[i].y-1)/block;
			for (int j=id*block+1;j<=q[i].y;j++)
			{
				change(id,cnt[id][a[j]],-1);
				cnt[id][a[j]]++;
				change(id,cnt[id][a[j]],1);
			}
			if (q[i].x&1) printf("%d\n",query(id,cnt[id][a[q[i].y]]));
			else printf("%d\n",cnt[id][a[q[i].y]]);
			for (int j=q[i].y;j>=id*block+1;j--)
			{
				change(id,cnt[id][a[j]],-1);
				cnt[id][a[j]]--;
				change(id,cnt[id][a[j]],1);
			}
		}
		else
		{
			int id=(q[i].x-1)/block+1;
			for (int j=id;j<=w;j++)
			{
				change(j,cnt[j][a[j]],-1);
				cnt[j][a[j]]--;
				change(j,cnt[j][a[j]],1);
				change(j,cnt[j][q[i].y],-1);
				cnt[j][q[i].y]++;
				change(j,cnt[j][q[i].y],1);
			}
			a[q[i].x]=q[i].y;
		}
	}
}


//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+100,block=1200;
int n,m,k,a[N],b[N*2],w,t[N*2];
int cnt[110][N*2],f[110][N],l;
struct node
{
	int op,x,y;
}q[N];
inline int lowbit(int x){return x&(-x);}
inline void change(int id,int x,int v)
{
	while (x>0)
	{
		f[id][x]+=v;
		x-=lowbit(x);
	}
}
inline int query(int id,int x)
{
	int ans=0;
	while (x<=m)
	{
		ans+=f[id][x];
		x+=lowbit(x);
	}
	return ans;
}
inline int read()
{
	int f=1,x=0;char s=getchar();
	while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
	while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
	return x*f;
}
int main()
{
	m=read();
	for (int i=1;i<=m;i++) a[i]=b[++w]=read();
	k=read();
	for (int i=1;i<=k;i++)
	{
		q[i].op=2-read(),q[i].x=read(),q[i].y=read();
		if (q[i].op==1) swap(q[i].x,q[i].y);
		if (q[i].op==1) b[++w]=q[i].y;
	}
	sort(b+1,b+1+w);
	w=unique(b+1,b+1+w)-b-1;
	for (int i=1;i<=m;i++) a[i]=lower_bound(b+1,b+w+1,a[i])-b;
	for (int i=1;i<=k;i++) if (q[i].op==1) q[i].y=lower_bound(b+1,b+w+1,q[i].y)-b;
	w=(n-1)/block+1;
	for (int i=1;i<=w;i++)
	{
		memcpy(f[i],f[i-1],sizeof(f[i]));
		memcpy(cnt[i],cnt[i-1],sizeof(cnt[i]));
		for (int j=(i-1)*block+1;j<=min(m,i*block);j++)
		{
			change(i,cnt[i][a[j]],-1);
			cnt[i][a[j]]++;
			change(i,cnt[i][a[j]],1);
		}
	}
	for (int i=1;i<=k;i++)
	{
		if (q[i].op==0)
		{
			if (q[i].x==1)
			{
				printf("%d\n",b[a[q[i].y]]);
				continue;
			}
			int id=(q[i].y-1)/block;
			for (int j=id*block+1;j<=q[i].y;j++)
			{
				change(id,cnt[id][a[j]],-1);
				cnt[id][a[j]]++;
				change(id,cnt[id][a[j]],1);
			}
			if (q[i].x&1) printf("%d\n",query(id,cnt[id][a[q[i].y]]));
			else printf("%d\n",cnt[id][a[q[i].y]]);
			for (int j=q[i].y;j>=id*block+1;j--)
			{
				change(id,cnt[id][a[j]],-1);
				cnt[id][a[j]]--;
				change(id,cnt[id][a[j]],1);
			}
		}
		else
		{
			int id=(q[i].x-1)/block+1;
			for (int j=id;j<=w;j++)
			{
				change(j,cnt[j][a[j]],-1);
				cnt[j][a[j]]--;
				change(j,cnt[j][a[j]],1);
				change(j,cnt[j][q[i].y],-1);
				cnt[j][q[i].y]++;
				change(j,cnt[j][q[i].y],1);
			}
			a[q[i].x]=q[i].y;
		}
	}
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int B=505;
const int N=200005;
int f[205][N];
int g[205][N];
int a[N],ar[N],nd,n,x;
map<int,int> mp;
int getid(int x){
	if (mp[x]) return mp[x];
	ar[mp[x]=++nd]=x;
	return nd;
}
int main(){
	scanf("%d",&n);
	int cnt=(n-1)/B+1;
	For(i,1,n) scanf("%d",&x),a[i]=getid(x);
	For(i,1,cnt){
		int L=(i-1)*B+1,R=min(i*B,n);
		memcpy(f[i],f[i-1],sizeof(f[i]));
		memcpy(g[i],g[i-1],sizeof(g[i]));
		For(j,L,R) g[i][++f[i][a[j]]]++;
	}
	int Q;
	scanf("%d",&Q);
	while (Q--){
		int tp,x,y;
		scanf("%d%d%d",&tp,&x,&y);
	 	if (tp==1){
	 		int be=(y-1)/B+1;
	 		For(i,be,cnt) g[i][f[i][a[y]]--]--;
	 		a[y]=getid(x);
	 		For(i,be,cnt) g[i][++f[i][a[y]]]++;
	 	}
	 	else if (x==1) printf("%d\n",ar[a[y]]);
	 	else{
	 		x&=1;
	 		int be=(y-1)/B+1,R=min(be*B,n);
	 		Rep(i,R,y+1) g[be][f[be][a[i]]--]--;
	 		printf("%d\n",x&1?g[be][f[be][a[y]]]:f[be][a[y]]);
	 		For(i,y+1,R) g[be][++f[be][a[i]]]++;
	 	}
	}
}//hello


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int B=505;
const int N=200005;
int f[205][N];
int g[205][N];
int a[N],ar[N],nd,n,x;
map<int,int> mp;
int getid(int x){
	if (mp[x]) return mp[x];
	ar[mp[x]=++nd]=x;
	return nd;
}
int main(){
	scanf("%d",&n);
	int cnt=(n-1)/B+1;
	For(i,1,n) scanf("%d",&x),a[i]=getid(x);
	For(i,1,cnt){
		int L=(i-1)*B+1,R=min(i*B,n);
		memcpy(f[i],f[i-1],sizeof(f[i]));
		memcpy(g[i],g[i-1],sizeof(g[i]));
		For(j,L,R) g[i][++f[i][a[j]]]++;
	}
	int Q;
	scanf("%d",&Q);
	while (Q--){
		int tp,x,y;
		scanf("%d%d%d",&tp,&x,&y);
	 	if (tp==1){
	 		int be=(y-1)/B+1;
	 		For(i,be,cnt) g[i][f[i][a[y]]--]--;
	 		a[y]=getid(x);
	 		For(i,be,cnt) g[i][++f[i][a[y]]]++;
	 	}
	 	else if (x==1) printf("%d\n",ar[a[y]]);
	 	else{
	 		x&=1;
	 		int be=(y-1)/B+1,R=min(be*B,n);
	 		Rep(i,R,y+1) g[be][f[be][a[i]]--]--;
	 		printf("%d\n",x&1?g[be][f[be][a[y]]]:f[be][a[y]]);
	 		For(i,y+1,R) g[be][++f[be][a[i]]]++;
	 	}
	}
}//hello//hello


/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___
           __|__|
          |  |___       */
#include <bits/stdc++.h>
#define ll long long
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define rbeg(i ,n ,a) for(ll i=n;i>=a;i--)
#define bega(i ,a ,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define mpi map <int , int> mp
#define mps map <int , int> ms
#define pb push_back
#define mp make_pair
#define all(x) x.begin() , x.end()
using namespace std;

std::vector<ll> seq[200001];

int main(){
    fast ;
    ll n , a , mx=0 , mx_ind , curr , temp ;
    cin >> n ;
    ll ar[n] ;
    beg(i , n) cin>>ar[i] ;
    beg(i , n){
    	seq[i].pb(i+1) ;
    	temp = 1 ; curr =ar[i] ;
    	bega(j , i+1 , n){
    		if( ar[j] == curr+1 ) temp++ , curr++ , seq[i].pb(j+1) ;
    	}
    	if( mx < temp ) mx = temp , mx_ind = i ;
    }
    cout<<mx<<endl;
    beg(i , seq[mx_ind].size()) cout << seq[mx_ind][i] << " " ;
    return 0;
}


/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___
           __|__|
          |  |___       */
#include <bits/stdc++.h>
#define ll long long
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define rbeg(i ,n ,a) for(ll i=n;i>=a;i--)
#define bega(i ,a ,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define mpi map <int , int> mp
#define mps map <int , int> ms
#define pb push_back
#define mp make_pair
#define all(x) x.begin() , x.end()
#define int_max 1e9
using namespace std ;

int main(){
    fast ;
    int n , max , mx=-1 ;
    cin >> n ;
    int ar[n] ;
    std::map<int, int> hash;
    std::vector<int> ans;
    beg(i , n){
        cin >> ar[i] ;
        if(hash[ar[i]] < hash[ar[i]-1]+1){
            hash[ar[i]] = hash[ar[i]-1]+1 ;
            if(hash[ar[i]] > mx){
                max = ar[i] ;
                mx = hash[ar[i]] ;
            }
        }
    }
    cout << mx << endl ;
    for(int i=n-1 ; i>=0 ; i--){
        if(ar[i] == max){
            ans.pb(i+1) ;
            max-- ;
        }
    }
    reverse(all(ans)) ;
    for(int i : ans) cout << i << " " ;
    return 0 ;
}


/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___
           __|__|
          |  |___       */
#include <bits/stdc++.h>
#define ll long long
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define rbeg(i ,n ,a) for(ll i=n;i>=a;i--)
#define bega(i ,a ,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define mpi map <int , int> mp
#define mps map <int , int> ms
#define pb push_back
#define mp make_pair
#define all(x) x.begin() , x.end()
using namespace std;

std::vector<int> ar[200001];

int main(){
    fast ;
    ll n , a , curr_v , curr_i , length , ma , start = 0 , ma_s=0 ;
    cin >> n ;
    std::vector< pair < int , int> > v;
    beg(i , n ){
        cin >> a ;
        v.pb( mp(a , i) ) ;
    }
    sort(all(v)) ;
    curr_v = v[0].first , length = 1 , curr_i = v[0].second ;
    ar[start].pb(v[0].second+1) ;
    beg1(i , n){
        if( v[i].first == curr_v+1 && v[i].second > curr_i ) curr_i = v[i].second , curr_v = v[i].first , length++ , ar[start].pb(v[i].second+1) ;
        else if( v[i].first > curr_v+1 || v[i].second < curr_i){
            if( ma >  length) ma = length , ma_s = start ;
            start = i ;
            curr_v = v[i].first , curr_i = v[i].second ;
            ar[start].pb(v[i].second+1) ;
        }
        if( i == n-1){
            if( ma <  length) ma = length , ma_s = start ;
        }
    }
    cout << ma << endl;
    beg(i , ar[ma_s].size()) cout << ar[ma_s][i] << " " ;
    return 0;
}


/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___
           __|__|
          |  |___       */
#include <bits/stdc++.h>
#define ll long long
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define rbeg(i ,n ,a) for(ll i=n;i>=a;i--)
#define bega(i ,a ,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define mpi map <int , int> mp
#define mps map <int , int> ms
#define pb push_back
#define mp make_pair
#define all(x) x.begin() , x.end()
using namespace std;

std::vector<int> ar[200001];

int main(){
    fast ;
    ll n , a , curr_v , curr_i , length , ma , start = 0 , ma_s=0 ;
    cin >> n ;
    std::vector< pair < int , int> > v;
    beg(i , n ){
        cin >> a ;
        v.pb( mp(a , i) ) ;
    }
    sort(all(v)) ;
    curr_v = v[0].first , length = 1 , curr_i = v[0].second ;
    ar[start].pb(v[0].second+1) ;
    beg1(i , n){
        if( v[i].first == curr_v+1 && v[i].second > curr_i ) curr_i = v[i].second , curr_v = v[i].first , length++ , ar[start].pb(v[i].second+1) ;
        else if( v[i].first > curr_v+1 || v[i].second < curr_i){
            if( ma <  length) ma = length , ma_s = start ;
            start = i ;
            curr_v = v[i].first , curr_i = v[i].second ;
            ar[start].pb(v[i].second+1) ;
            length = 1 ;
        }
        if( i == n-1){
            if( ma <  length) ma = length , ma_s = start ;
        }
    }
    cout << ma << endl;
    beg(i , ar[ma_s].size()) cout << ar[ma_s][i] << " " ;
    return 0;
}


/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___
           __|__|
          |  |___       */
#include <bits/stdc++.h>
#define ll long long
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define rbeg(i ,n ,a) for(ll i=n;i>=a;i--)
#define bega(i ,a ,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define mpi map <int , int> mp
#define mps map <int , int> ms
#define pb push_back
#define mp make_pair
#define all(x) x.begin() , x.end()
using namespace std;

std::vector<int> ar[200001];

int main(){
    fast ;
    ll n , a , curr_v , curr_i , length , ma , start = 0 , ma_s=0 ;
    cin >> n ;
    std::vector< pair < int , int> > v;
    beg(i , n ){
        cin >> a ;
        v.pb( mp(a , i) ) ;
    }
    sort(all(v)) ;
    curr_v = v[0].first , length = 1 , curr_i = v[0].second ;
    ar[start].pb(v[0].second+1) ;
    beg1(i , n){
        if( v[i].first == curr_v+1 && v[i].second > curr_i ) curr_i = v[i].second , curr_v = v[i].first , length++ , ar[start].pb(v[i].second+1) ;
        else if( v[i].first > curr_v+1 || v[i].second < curr_i){
            if( ma >  length) ma = length , ma_s = start ;
            start = i ;
            curr_v = v[i].first , curr_i = v[i].second ;
            ar[start].pb(v[i].second+1) ;
            length = 1 ;
        }
        if( i == n-1){
            if( ma <  length) ma = length , ma_s = start ;
        }
    }
    cout << ma << endl;
    beg(i , ar[ma_s].size()) cout << ar[ma_s][i] << " " ;
    return 0;
}


/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___
           __|__|
          |  |___       */
#include <bits/stdc++.h>
#define ll long long
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define rbeg(i ,n ,a) for(ll i=n;i>=a;i--)
#define bega(i ,a ,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define mpi map <int , int> mpa
#define mps map <int , int> ms
#define pb push_back
#define mp make_pair
#define all(x) x.begin() , x.end()
using namespace std;

std::vector<int> ar[200001];
mpi ;

int main(){
    fast ;
    ll n , a , curr_v , curr_i , length , ma=0 , start = 0 , ma_s=0 ;
    cin >> n ;
    std::vector< pair < int , int> > v;
    beg(i , n ){
        cin >> a ;
        v.pb( mp(a , i) ) ;
    }
    sort(all(v)) ;
    beg( j , n){
        curr_v = v[j].first , length = 1 , curr_i = v[j].second , start = j;
        ar[start].pb(v[j].second+1) ;
        if(!mpa.count(v[j].first)){
            mpa.insert( pair<int , int> (v[j].first, 1)) ;
            bega(i , j+1 , n){
                if( v[i].first == curr_v+1 && v[i].second > curr_i ) curr_i = v[i].second , curr_v = v[i].first , length++ ,                        mpa.insert( pair<int , int> (v[i].first , 1)) , ar[start].pb(v[i].second+1) ;
                else if( v[i].first > curr_v+1){
                    if( ma <  length) ma = length , ma_s = start ;
                    break ;
                }
                if( i == n-1){
                    if( ma <  length) ma = length , ma_s = start ;
                }
            }
        }
    }
    cout << ma << endl;
    beg(i , ar[ma_s].size()) cout << ar[ma_s][i] << " " ;
    return 0;
}


 #include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   map<long long int,long long int>ma;
    map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

            if(ind[k]==0)
            {
                 ind[k]=i;
            }
                ;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<=maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
    map<long long int,long long int>ma;
    map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

         if(ma[k-1]+1>ma[k])
              ind[k]=i;
               ma[k]=max(ma[k],ma[k-1]+1);

            if(ma[k]>maxi)
            {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


 #include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   map<long long int,long long int>ma;
    map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

          if(ma[k]<ma[k-1]+1)
          {
            if(ind[k]==0)
            {
                 ind[k]=i;
            }
                ;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                maxi=ma[k];
                l=k;
            }
          }

    }
    cout<<maxi<<endl;

    for(i=0;i<maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   unordered_map<long long int,long long int>ma;
    unordered_map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

            if(ma[k-1]+1>ma[k] && ind[k-1]<i )
            {
                 ind[k]=i;
                 ma[k]=ma[k-1]+1;
            }

            if(ma[k]>maxi)
            {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
    map<long long int,long long int>ma;
    map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

            if(ma[k-1]+1>=ma[k] && ind[k-1]<i )
            {
                ind[k]=i;
               ma[k]=max(ma[k],ma[k-1]+1);
            }

            if(ma[k]>maxi)
            {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   unordered_map<long long int,long long int>ma;
    unordered_map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

            if(ma[k-1]+1>ma[k] && ind[k-1]<i )
            {
                 ind[k]=i;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
            {
                maxi=ma[k];
                l=k;
            }

            }

    }
    cout<<maxi<<endl;

    for(i=0;i<maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
    map<long long int,long long int>ma;
    map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

            if(ma[k-1]+1>ma[k])
              ind[k]=i;
            ma[k]=max(ma[k],ma[k-1]+1);

            if(ma[k]>maxi)
            {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;
    vector<long long int>V;
    for(i=0;i<maxi;i++)
    {
        V.push_back(ind[l-maxi+i+1]);
    }
  sort(V.begin(),V.end());
    for(i=0;i<V.size();i++)
    {
        cout<<V[i]<<" ";
    }
}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
    map<long long int,long long int>ma;
    map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

            if(ma[k-1]+1>ma[k] && ind[k-1]<i )
            {
                ind[k]=i;
               ma[k]=max(ma[k],ma[k-1]+1);
            }

            if(ma[k]>maxi)
            {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   unordered_map<long long int,long long int>ma;
    unordered_map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

            if(ind[k]!=0)
            {
                 ind[k]=i;
            }
                ;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<=maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   unordered_map<long long int,long long int>ma;
    unordered_map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

                 ind[k]=i;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   unordered_map<long long int,long long int>ma;
    unordered_map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

                 ind[k]=i;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<=maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1,g1;
    cin>>n;
  map<long long int,long long int>ma;
    long long int A[n+1];
   // unordered_map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;
       A[i]=k;

               //  ind[k]=i;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                  maxi=ma[k];
                  l=k;
                    }

    }
    cout<<maxi<<endl;
    a=l-maxi+1;
   // cout<<a<<" ";
    for(i=1;i<=n;i++)
    { //cout<<A[i]<<" ";
       if(A[i]==a)
       {
           cout<<i<<" ";
            a++;
       }

    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   unordered_map<long long int,long long int>ma;
    unordered_map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

            if(ind[k]==0)
            {
                 ind[k]=i;
            }
                ;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<=maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
    map<long long int,long long int>ma;
    map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

               ma[k]=max(ma[k],ma[k-1]+1);
           if(ma[k-1]+1>ma[k])
              ind[k]=i;
            if(ma[k]>maxi)
            {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


 #include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   map<long long int,long long int>ma;
    map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

            if(ind[k]==0)
            {
                 ind[k]=i;
            }
                ;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                maxi=ma[k];
                l=k;
            }

    }
    cout<<maxi<<endl;

    for(i=0;i<maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


 #include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   map<long long int,long long int>ma;
    map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

          if(ma[k]<ma[k-1]+1)
          {

            if(ind[k]==0)
            {
                 ind[k]=i;
            }
                ;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                maxi=ma[k];
                l=k;
            }
          }

    }
    cout<<maxi<<endl;

    for(i=0;i<=maxi;i++)
    {
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
   unordered_map<long long int,long long int>ma;
    long long int A[n+1];
   // unordered_map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;
       A[i]=k;

               //  ind[k]=i;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                  maxi=ma[k];
                  l=k;
                    }

    }
    cout<<maxi<<endl;
    a=l-maxi+1;
   // cout<<a<<" ";
    for(i=1;i<=n;i++)
    { //cout<<A[i]<<" ";
       if(A[i]==a)
       {
           cout<<i<<" ";
            a++;
       }

    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
    map<long long int,long long int>ma;
    map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;

        if(ma[k]==0)
        {
            ma[k]=ma[k-1]+1;
            ind[k]=i;
            if(ma[k]>maxi)
            {
                maxi=ma[k];
                l=k;
            }
        }
    }
    cout<<maxi<<endl;

    for(i=0;i<maxi;i++)
    {
       // cout<<l-maxi+i<<endl;
        cout<<ind[l-maxi+i+1]<<" ";
    }

}


#include<bits/stdc++.h>
#include<queue>
#include<stack>
//STAY_CALM_STAY_STRONG
#define MAX 1000000
using namespace std;
long long int MOD=1e9+7;
long long int INF=1e15;
long long int dp[5001][5001]={0};
int main()
{
    // ios_base::sync_with_stdio(false);
     //cin.tie(NULL);
     //cout.tie(NULL);
     long long int e,i,j,k,l,m,n,mini,o,p,u,v,x,y=0,z,t,ans=0,a,b,w,c,r,d,len,maxi=0;
     string s,s1;
    cin>>n;
  map<long long int,long long int>ma;
    long long int A[n+1];
   // unordered_map<long long int ,long long int>ind;
    for(i=1;i<=n;i++)
    {
        cin>>k;
       A[i]=k;

               //  ind[k]=i;
                 ma[k]=ma[k-1]+1;
                  if(ma[k]>maxi)
                  {
                  maxi=ma[k];
                  l=k;
                    }

    }
    cout<<maxi<<endl;
    a=l-maxi+1;
   // cout<<a<<" ";
    for(i=1;i<=n;i++)
    { //cout<<A[i]<<" ";
       if(A[i]==a)
       {
           cout<<i<<" ";
            a++;
       }

    }

}


////////////////<------------- Xorcestor_X -------------->////////////////
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>
#include <utility>
#include <set>
#include <deque>
#include <string>

using namespace std;
#define endl "\n"
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 1e16
#define mod 1000000007
#define mod2 998244353
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) fr(i,0,n-1) cin>>arr[i]
#define carr2(arr,n,m) fr(i,0,n-1) fr(j,0,m-1) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define debugx(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debugx("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
const ll N = 105;
typedef ll mt[N][N];

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b) { return b==0 ? a : gcd(b, a%b); }

ll reduce(ll a,ll m)
{
  a%=m;
  a+=m;
  a%=m;
  return a;
}

ll Extended_gcd(ll a,ll b,ll& x,ll& y)
{
  if(a==0)
  {
    x=0;
    y=1;
    return b;
  }
  else
  {
    ll x1,y1;
    ll g=Extended_gcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return g;
  }
}

bool leap(ll y)
{
  if(y%400==0) return true;
  if((y%4==0)&&(y%100!=0)) return true;
  return false;
}

ll isprime(ll n)
{
  if(n==1) return false;
  if(n==2) return true;
  for(int i=2;i*i<=n;i++)
  {
    if(n%i==0) return false;
  }
  return true;
}

bool prime[2000010];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));
    prime[1]=false;
    for (int p=2; p*p<=2000001; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=2000001; i += p)
                prime[i] = false;
        }
    }
}

// vector<ll> prime_vec[1000010];
// void modified_SieveOfEratosthenes()
// {
//     //prime[1]=false;
//     for (int p=2; p*p<=1000001; p++)
//     {
//         if (prime_vec[p].size()==0)
//         {
//             for (int i=p*2; i<=1000001; i += p)
//                 prime_vec[i].pb(p);
//         }
//     }
// }

////*** Various Exponentiation Functions ***////

ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}

// ll result[1000010];
// ll tempo[1000010];
// ll per[1000010];
//
//
// void permutation_exp(ll n,ll x)
// {
//   fr(o,1,n)
//   {
//     result[o]=o;
//   }
//
//   while(x>0)
//   {
//     if(x&1)
//     {
//       fr(o,1,n)
//       {
//         tempo[o]=result[o];
//       }
//
//       fr(o,1,n)
//       {
//         result[o]=tempo[per[o]];
//       }
//     }
//
//     fr(o,1,n)
//     {
//       tempo[o]=per[o];
//     }
//
//     fr(o,1,n)
//     {
//       per[o]=tempo[tempo[o]];
//     }
//     x>>=1;
//   }
// }

ll len;
ll ultimate[110][110];

void matrix_exp(ll arr[100][110],ll n)
{
  //ll len=4;
  ll res[110][110];
  rep(o,len)
  {
    rep(p,len)
    {
      if(o!=p)
      res[o][p]=0;
      else
      res[o][p]=1;
    }
  }

  ll temp[110][110];

  while(n)
  {
    if(n&1)
    {
      rep(x,len)
      {
        rep(y,len)
        {
          temp[x][y]=0;
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          fr(z,0,len-1)
          {
            temp[i][j]+=reduce(res[i][z]*arr[z][j],mod);
          }
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          res[i][j]=reduce(temp[i][j],mod);
        }
      }
    }

    rep(x,len)
    {
      rep(y,len)
      {
        temp[x][y]=0;
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        fr(z,0,len-1)
        {
          temp[i][j]+=reduce(arr[i][z]*arr[z][j],mod);
          temp[i][j]%=mod;
        }
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        arr[i][j]=reduce(temp[i][j],mod);
      }
    }

    n/=2;
  }

  fr(i,0,len-1)
  {
    fr(j,0,len-1)
    {
      ultimate[i][j]=reduce(res[i][j],mod);
    }
  }
}

ll modpow(ll a, ll b,ll x)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%x;
        a = (a * a)%x;
        b >>= 1;
    }
    return res;
}

////*** End of Various Exponentiation Functions ***////

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
        // Update y and x
        y = x - q * y;
        x = t;
    }
    // Make x positive
    if (x < 0)
       x += m0;
    return x;
}

ll int_sqrt(ll h)
{
  ll g=(ll)sqrt(h);
  g++;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  return -1;
}

ll lpf[1000001] = {};

void precompute()
{
  fr(i,2,1000000)
  {
    if(!lpf[i])
    {
      for(ll j=i;j<=1000000;j+=i)
      {
        if(!lpf[j])
        lpf[j]=i;
      }
    }
  }
}

ll fact[2000010];

void compute_fact()
{
  fact[0]=1;
  fr(o,1,2000004)
  {
    fact[o]=(fact[o-1]*o)%mod;
  }
}

ll ncr_mod(ll n,ll r)
{
  if(r==0||n==r) return 1;
  else return (((fact[n]*modInverse(fact[r],mod))%mod)*modInverse(fact[n-r],mod))%mod;
}

ll f(ll x)
{
  ll total=0;
  return total;
}

ll ternary_search(ll l, ll r)
{              //set the error limit here
    while (r - l > 10)
    {
        ll m1 = l + (r - l) / 3;
        ll m2 = r - (r - l) / 3;
        ll f1 = f(m1);      //evaluates the function at m1
        ll f2 = f(m2);      //evaluates the function at m2
        if (f1 > f2)
            l = m1;
        else
            r = m2;
    }
    ll mino=f(l);
    ll mino_x=l;

    fr(o,l,r)
    {
      if(f(o)<mino)
      {
        mino_x=o;
        mino=f(o);
      }
    }
    return f(mino_x);
}

// ll tree[2000010];
// void build(ll* a,ll v,ll tl,ll tr)
// {
//   if(tl==tr)
//   {
//     tree[v]=((a[tl]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     build(a,v*2,tl,tm);
//     build(a,v*2+1,tm+1,tr);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
// ll query(ll v,ll tl,ll tr,ll l,ll r)
// {
//   if(l>r) return 0;
//   if(l==tl&&r==tr) return tree[v];
//   ll tm=(tl+tr)/2;
//   return query(v*2,tl,tm,l,minim(r,tm))+query(v*2+1,tm+1,tr,maxim(l,tm+1),r);
// }
//
//
// void update(ll v,ll tl,ll tr,ll pos,ll new_val)
// {
//   if(tl==tr)
//   {
//     tree[v]=((arr[pos]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     if(pos<=tm) update(v*2,tl,tm,pos,new_val);
//     else update(v*2+1,tm+1,tr,pos,new_val);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
//
// ll find_kth(ll v,ll tl,ll tr,ll k)
// {
//   if(k>tree[v]) return -1;
//   if(tl==tr) return tl;
//   ll tm=(tl+tr)/2;
//   if(tree[v*2]>=k) return find_kth(v*2,tl,tm,k);
//   else return find_kth(v*2+1,tm+1,tr,k-tree[v*2]);
// }

ll far[1000010];
ll farsum[1000010];

ll func(ll x)
{
  return (x*(x+1))/2;
}

ll bs(ll low,ll high,ll target)
{
  while(low+4<high)
  {
    ll mid=(low+high)/2;
    //increasing function with inclusion
    if(func(mid)<target)
    {
      low=mid;
    }
    else
    {
      high=mid-1;
    }
  }

  frr(o,high,low)
  {
    if(func(o)<target) return o;
  }

  return -1;
}

ll lpfx(ll x)
{
  if(x%2==0) return 2;
  else
  {
    for(int z=3;z*z<=x;z+=2)
    {
      if(x%z==0) return z;
    }
  }
  return x;
}

ll fz(ll n)
{
  ll o=1;
  while(o<=n)
  {
    o*=2;
  }
  return o;
}

ll arr[1000010];
map<ll,ll> mx;
map<ll,string> vx;

int main()
{
  fast;

  #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif

  c(n);
  carr(arr,n);
  rep(o,n)
  {
    if(mx.find(arr[o]-1)!=mx.end())
    {
      if(mx[arr[o]-1]+1>mx[arr[o]])
      {
        ostringstream str1;
        str1<<o+1;
        string f=vx[arr[o]-1];
        f+=" "+str1.str();
        // f.pb(o+1);
        vx[arr[o]]=f;
        mx[arr[o]]=mx[arr[o]-1]+1;
      }
    }
    else
    {
      if(mx.find(arr[o])==mx.end())
      {
        mx[arr[o]]=1;
        // vector<ll> temp;
        // temp.pb(o+1);
        ostringstream str1;
        str1<<o+1;
        vx[arr[o]]=str1.str();
      }
    }
  }

  ll maxo=0;
  rep(o,n)
  {
    maxo=maxim(maxo,mx[arr[o]]);
  }

  // debug(maxo);
  // rep(o,n)
  // {
  //   cout<<mx[arr[o]]<<" ";
  // }
  // cout<<endl;

  rep(o,n)
  {
    if(mx[arr[o]]==maxo)
    {
      cout<<maxo<<endl;
      ll p=arr[o];
      string ans="";
      ll index=o;
      while(maxo)
      {
        if(arr[index]==p)
        {
          ostringstream ssd;
          ssd<<index+1;
          ans=ssd.str()+" "+ans;
          p--;
          maxo--;
        }
        index--;
      }
      cout<<ans<<endl;
      break;
    }
  }
  return 0;
}


////////////////<------------- Xorcestor_X -------------->////////////////
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>
#include <utility>
#include <set>
#include <deque>
#include <string>

using namespace std;
#define endl "\n"
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 1e16
#define mod 1000000007
#define mod2 998244353
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) fr(i,0,n-1) cin>>arr[i]
#define carr2(arr,n,m) fr(i,0,n-1) fr(j,0,m-1) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define debugx(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debugx("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
const ll N = 105;
typedef ll mt[N][N];

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b) { return b==0 ? a : gcd(b, a%b); }

ll reduce(ll a,ll m)
{
  a%=m;
  a+=m;
  a%=m;
  return a;
}

ll Extended_gcd(ll a,ll b,ll& x,ll& y)
{
  if(a==0)
  {
    x=0;
    y=1;
    return b;
  }
  else
  {
    ll x1,y1;
    ll g=Extended_gcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return g;
  }
}

bool leap(ll y)
{
  if(y%400==0) return true;
  if((y%4==0)&&(y%100!=0)) return true;
  return false;
}

ll isprime(ll n)
{
  if(n==1) return false;
  if(n==2) return true;
  for(int i=2;i*i<=n;i++)
  {
    if(n%i==0) return false;
  }
  return true;
}

bool prime[2000010];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));
    prime[1]=false;
    for (int p=2; p*p<=2000001; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=2000001; i += p)
                prime[i] = false;
        }
    }
}

// vector<ll> prime_vec[1000010];
// void modified_SieveOfEratosthenes()
// {
//     //prime[1]=false;
//     for (int p=2; p*p<=1000001; p++)
//     {
//         if (prime_vec[p].size()==0)
//         {
//             for (int i=p*2; i<=1000001; i += p)
//                 prime_vec[i].pb(p);
//         }
//     }
// }

////*** Various Exponentiation Functions ***////

ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}

// ll result[1000010];
// ll tempo[1000010];
// ll per[1000010];
//
//
// void permutation_exp(ll n,ll x)
// {
//   fr(o,1,n)
//   {
//     result[o]=o;
//   }
//
//   while(x>0)
//   {
//     if(x&1)
//     {
//       fr(o,1,n)
//       {
//         tempo[o]=result[o];
//       }
//
//       fr(o,1,n)
//       {
//         result[o]=tempo[per[o]];
//       }
//     }
//
//     fr(o,1,n)
//     {
//       tempo[o]=per[o];
//     }
//
//     fr(o,1,n)
//     {
//       per[o]=tempo[tempo[o]];
//     }
//     x>>=1;
//   }
// }

ll len;
ll ultimate[110][110];

void matrix_exp(ll arr[100][110],ll n)
{
  //ll len=4;
  ll res[110][110];
  rep(o,len)
  {
    rep(p,len)
    {
      if(o!=p)
      res[o][p]=0;
      else
      res[o][p]=1;
    }
  }

  ll temp[110][110];

  while(n)
  {
    if(n&1)
    {
      rep(x,len)
      {
        rep(y,len)
        {
          temp[x][y]=0;
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          fr(z,0,len-1)
          {
            temp[i][j]+=reduce(res[i][z]*arr[z][j],mod);
          }
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          res[i][j]=reduce(temp[i][j],mod);
        }
      }
    }

    rep(x,len)
    {
      rep(y,len)
      {
        temp[x][y]=0;
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        fr(z,0,len-1)
        {
          temp[i][j]+=reduce(arr[i][z]*arr[z][j],mod);
          temp[i][j]%=mod;
        }
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        arr[i][j]=reduce(temp[i][j],mod);
      }
    }

    n/=2;
  }

  fr(i,0,len-1)
  {
    fr(j,0,len-1)
    {
      ultimate[i][j]=reduce(res[i][j],mod);
    }
  }
}

ll modpow(ll a, ll b,ll x)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%x;
        a = (a * a)%x;
        b >>= 1;
    }
    return res;
}

////*** End of Various Exponentiation Functions ***////

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
        // Update y and x
        y = x - q * y;
        x = t;
    }
    // Make x positive
    if (x < 0)
       x += m0;
    return x;
}

ll int_sqrt(ll h)
{
  ll g=(ll)sqrt(h);
  g++;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  return -1;
}

ll lpf[1000001] = {};

void precompute()
{
  fr(i,2,1000000)
  {
    if(!lpf[i])
    {
      for(ll j=i;j<=1000000;j+=i)
      {
        if(!lpf[j])
        lpf[j]=i;
      }
    }
  }
}

ll fact[2000010];

void compute_fact()
{
  fact[0]=1;
  fr(o,1,2000004)
  {
    fact[o]=(fact[o-1]*o)%mod;
  }
}

ll ncr_mod(ll n,ll r)
{
  if(r==0||n==r) return 1;
  else return (((fact[n]*modInverse(fact[r],mod))%mod)*modInverse(fact[n-r],mod))%mod;
}

ll f(ll x)
{
  ll total=0;
  return total;
}

ll ternary_search(ll l, ll r)
{              //set the error limit here
    while (r - l > 10)
    {
        ll m1 = l + (r - l) / 3;
        ll m2 = r - (r - l) / 3;
        ll f1 = f(m1);      //evaluates the function at m1
        ll f2 = f(m2);      //evaluates the function at m2
        if (f1 > f2)
            l = m1;
        else
            r = m2;
    }
    ll mino=f(l);
    ll mino_x=l;

    fr(o,l,r)
    {
      if(f(o)<mino)
      {
        mino_x=o;
        mino=f(o);
      }
    }
    return f(mino_x);
}

// ll tree[2000010];
// void build(ll* a,ll v,ll tl,ll tr)
// {
//   if(tl==tr)
//   {
//     tree[v]=((a[tl]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     build(a,v*2,tl,tm);
//     build(a,v*2+1,tm+1,tr);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
// ll query(ll v,ll tl,ll tr,ll l,ll r)
// {
//   if(l>r) return 0;
//   if(l==tl&&r==tr) return tree[v];
//   ll tm=(tl+tr)/2;
//   return query(v*2,tl,tm,l,minim(r,tm))+query(v*2+1,tm+1,tr,maxim(l,tm+1),r);
// }
//
//
// void update(ll v,ll tl,ll tr,ll pos,ll new_val)
// {
//   if(tl==tr)
//   {
//     tree[v]=((arr[pos]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     if(pos<=tm) update(v*2,tl,tm,pos,new_val);
//     else update(v*2+1,tm+1,tr,pos,new_val);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
//
// ll find_kth(ll v,ll tl,ll tr,ll k)
// {
//   if(k>tree[v]) return -1;
//   if(tl==tr) return tl;
//   ll tm=(tl+tr)/2;
//   if(tree[v*2]>=k) return find_kth(v*2,tl,tm,k);
//   else return find_kth(v*2+1,tm+1,tr,k-tree[v*2]);
// }

ll far[1000010];
ll farsum[1000010];

ll func(ll x)
{
  return (x*(x+1))/2;
}

ll bs(ll low,ll high,ll target)
{
  while(low+4<high)
  {
    ll mid=(low+high)/2;
    //increasing function with inclusion
    if(func(mid)<target)
    {
      low=mid;
    }
    else
    {
      high=mid-1;
    }
  }

  frr(o,high,low)
  {
    if(func(o)<target) return o;
  }

  return -1;
}

ll lpfx(ll x)
{
  if(x%2==0) return 2;
  else
  {
    for(int z=3;z*z<=x;z+=2)
    {
      if(x%z==0) return z;
    }
  }
  return x;
}

ll fz(ll n)
{
  ll o=1;
  while(o<=n)
  {
    o*=2;
  }
  return o;
}

ll arr[1000010];
map<ll,ll> mx;
map<ll,string> vx;

int main()
{
  fast;

  #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif

  c(n);
  carr(arr,n);
  rep(o,n)
  {
    if(mx.find(arr[o]-1)!=mx.end())
    {
        mx[arr[o]]=mx[arr[o]-1]+1;
    }
    else
    {
      if(mx.find(arr[o])==mx.end())
      {
        mx[arr[o]]=1;
      }
    }
  }

  ll maxo=0;
  rep(o,n)
  {
    maxo=maxim(maxo,mx[arr[o]]);
  }

  // debug(maxo);
  // rep(o,n)
  // {
  //   cout<<mx[arr[o]]<<" ";
  // }
  // cout<<endl;

  rep(o,n)
  {
    if(mx[arr[o]]==maxo)
    {
      cout<<maxo<<endl;
      ll p=arr[o];
      string ans="";
      ll index=o;
      while(1)
      {
        if(arr[index]==p)
        {
          ostringstream ssd;
          ssd<<index+1;
          ans=ssd.str()+" "+ans;
          p--;
        }
        index--;
        if(p==arr[o]-maxo) break;
      }
      cout<<ans<<endl;
      break;
    }
  }
  return 0;
}


////////////////<------------- Xorcestor_X -------------->////////////////
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>
#include <utility>
#include <set>
#include <deque>
#include <string>

using namespace std;
#define endl "\n"
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 1e16
#define mod 1000000007
#define mod2 998244353
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) fr(i,0,n-1) cin>>arr[i]
#define carr2(arr,n,m) fr(i,0,n-1) fr(j,0,m-1) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define debugx(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debugx("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
const ll N = 105;
typedef ll mt[N][N];

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b) { return b==0 ? a : gcd(b, a%b); }

ll reduce(ll a,ll m)
{
  a%=m;
  a+=m;
  a%=m;
  return a;
}

ll Extended_gcd(ll a,ll b,ll& x,ll& y)
{
  if(a==0)
  {
    x=0;
    y=1;
    return b;
  }
  else
  {
    ll x1,y1;
    ll g=Extended_gcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return g;
  }
}

bool leap(ll y)
{
  if(y%400==0) return true;
  if((y%4==0)&&(y%100!=0)) return true;
  return false;
}

ll isprime(ll n)
{
  if(n==1) return false;
  if(n==2) return true;
  for(int i=2;i*i<=n;i++)
  {
    if(n%i==0) return false;
  }
  return true;
}

bool prime[2000010];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));
    prime[1]=false;
    for (int p=2; p*p<=2000001; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=2000001; i += p)
                prime[i] = false;
        }
    }
}

// vector<ll> prime_vec[1000010];
// void modified_SieveOfEratosthenes()
// {
//     //prime[1]=false;
//     for (int p=2; p*p<=1000001; p++)
//     {
//         if (prime_vec[p].size()==0)
//         {
//             for (int i=p*2; i<=1000001; i += p)
//                 prime_vec[i].pb(p);
//         }
//     }
// }

////*** Various Exponentiation Functions ***////

ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}

// ll result[1000010];
// ll tempo[1000010];
// ll per[1000010];
//
//
// void permutation_exp(ll n,ll x)
// {
//   fr(o,1,n)
//   {
//     result[o]=o;
//   }
//
//   while(x>0)
//   {
//     if(x&1)
//     {
//       fr(o,1,n)
//       {
//         tempo[o]=result[o];
//       }
//
//       fr(o,1,n)
//       {
//         result[o]=tempo[per[o]];
//       }
//     }
//
//     fr(o,1,n)
//     {
//       tempo[o]=per[o];
//     }
//
//     fr(o,1,n)
//     {
//       per[o]=tempo[tempo[o]];
//     }
//     x>>=1;
//   }
// }

ll len;
ll ultimate[110][110];

void matrix_exp(ll arr[100][110],ll n)
{
  //ll len=4;
  ll res[110][110];
  rep(o,len)
  {
    rep(p,len)
    {
      if(o!=p)
      res[o][p]=0;
      else
      res[o][p]=1;
    }
  }

  ll temp[110][110];

  while(n)
  {
    if(n&1)
    {
      rep(x,len)
      {
        rep(y,len)
        {
          temp[x][y]=0;
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          fr(z,0,len-1)
          {
            temp[i][j]+=reduce(res[i][z]*arr[z][j],mod);
          }
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          res[i][j]=reduce(temp[i][j],mod);
        }
      }
    }

    rep(x,len)
    {
      rep(y,len)
      {
        temp[x][y]=0;
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        fr(z,0,len-1)
        {
          temp[i][j]+=reduce(arr[i][z]*arr[z][j],mod);
          temp[i][j]%=mod;
        }
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        arr[i][j]=reduce(temp[i][j],mod);
      }
    }

    n/=2;
  }

  fr(i,0,len-1)
  {
    fr(j,0,len-1)
    {
      ultimate[i][j]=reduce(res[i][j],mod);
    }
  }
}

ll modpow(ll a, ll b,ll x)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%x;
        a = (a * a)%x;
        b >>= 1;
    }
    return res;
}

////*** End of Various Exponentiation Functions ***////

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
        // Update y and x
        y = x - q * y;
        x = t;
    }
    // Make x positive
    if (x < 0)
       x += m0;
    return x;
}

ll int_sqrt(ll h)
{
  ll g=(ll)sqrt(h);
  g++;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  return -1;
}

ll lpf[1000001] = {};

void precompute()
{
  fr(i,2,1000000)
  {
    if(!lpf[i])
    {
      for(ll j=i;j<=1000000;j+=i)
      {
        if(!lpf[j])
        lpf[j]=i;
      }
    }
  }
}

ll fact[2000010];

void compute_fact()
{
  fact[0]=1;
  fr(o,1,2000004)
  {
    fact[o]=(fact[o-1]*o)%mod;
  }
}

ll ncr_mod(ll n,ll r)
{
  if(r==0||n==r) return 1;
  else return (((fact[n]*modInverse(fact[r],mod))%mod)*modInverse(fact[n-r],mod))%mod;
}

ll f(ll x)
{
  ll total=0;
  return total;
}

ll ternary_search(ll l, ll r)
{              //set the error limit here
    while (r - l > 10)
    {
        ll m1 = l + (r - l) / 3;
        ll m2 = r - (r - l) / 3;
        ll f1 = f(m1);      //evaluates the function at m1
        ll f2 = f(m2);      //evaluates the function at m2
        if (f1 > f2)
            l = m1;
        else
            r = m2;
    }
    ll mino=f(l);
    ll mino_x=l;

    fr(o,l,r)
    {
      if(f(o)<mino)
      {
        mino_x=o;
        mino=f(o);
      }
    }
    return f(mino_x);
}

// ll tree[2000010];
// void build(ll* a,ll v,ll tl,ll tr)
// {
//   if(tl==tr)
//   {
//     tree[v]=((a[tl]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     build(a,v*2,tl,tm);
//     build(a,v*2+1,tm+1,tr);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
// ll query(ll v,ll tl,ll tr,ll l,ll r)
// {
//   if(l>r) return 0;
//   if(l==tl&&r==tr) return tree[v];
//   ll tm=(tl+tr)/2;
//   return query(v*2,tl,tm,l,minim(r,tm))+query(v*2+1,tm+1,tr,maxim(l,tm+1),r);
// }
//
//
// void update(ll v,ll tl,ll tr,ll pos,ll new_val)
// {
//   if(tl==tr)
//   {
//     tree[v]=((arr[pos]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     if(pos<=tm) update(v*2,tl,tm,pos,new_val);
//     else update(v*2+1,tm+1,tr,pos,new_val);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
//
// ll find_kth(ll v,ll tl,ll tr,ll k)
// {
//   if(k>tree[v]) return -1;
//   if(tl==tr) return tl;
//   ll tm=(tl+tr)/2;
//   if(tree[v*2]>=k) return find_kth(v*2,tl,tm,k);
//   else return find_kth(v*2+1,tm+1,tr,k-tree[v*2]);
// }

ll far[1000010];
ll farsum[1000010];

ll func(ll x)
{
  return (x*(x+1))/2;
}

ll bs(ll low,ll high,ll target)
{
  while(low+4<high)
  {
    ll mid=(low+high)/2;
    //increasing function with inclusion
    if(func(mid)<target)
    {
      low=mid;
    }
    else
    {
      high=mid-1;
    }
  }

  frr(o,high,low)
  {
    if(func(o)<target) return o;
  }

  return -1;
}

ll lpfx(ll x)
{
  if(x%2==0) return 2;
  else
  {
    for(int z=3;z*z<=x;z+=2)
    {
      if(x%z==0) return z;
    }
  }
  return x;
}

ll fz(ll n)
{
  ll o=1;
  while(o<=n)
  {
    o*=2;
  }
  return o;
}

ll arr[1000010];
map<ll,ll> mx;
map<ll,string> vx;

int main()
{
  fast;

  #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif

  c(n);
  carr(arr,n);
  rep(o,n)
  {
    if(mx.find(arr[o]-1)!=mx.end())
    {
        mx[arr[o]]=mx[arr[o]-1]+1;
    }
    else
    {
      if(mx.find(arr[o])==mx.end())
      {
        mx[arr[o]]=1;
      }
    }
  }

  ll maxo=0;
  rep(o,n)
  {
    maxo=maxim(maxo,mx[arr[o]]);
  }

  // debug(maxo);
  // rep(o,n)
  // {
  //   cout<<mx[arr[o]]<<" ";
  // }
  // cout<<endl;

  rep(o,n)
  {
    if(mx[arr[o]]==maxo)
    {
      cout<<maxo<<endl;
      ll p=arr[o];
      string ans="";
      ll index=o;
      while(1)
      {
        if(arr[index]==p)
        {
          ostringstream ssd;
          ssd<<index+1;
          ans=ssd.str()+" "+ans;
          p--;
        }
        index--;
        if(index==-1) break;
        if(p==arr[o]-maxo) break;
      }
      cout<<ans<<endl;
      break;
    }
  }
  return 0;
}


////////////////<------------- Xorcestor_X -------------->////////////////
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>
#include <utility>
#include <set>
#include <deque>
#include <string>

using namespace std;
#define endl "\n"
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 1e16
#define mod 1000000007
#define mod2 998244353
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) fr(i,0,n-1) cin>>arr[i]
#define carr2(arr,n,m) fr(i,0,n-1) fr(j,0,m-1) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define debugx(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debugx("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
const ll N = 105;
typedef ll mt[N][N];

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b) { return b==0 ? a : gcd(b, a%b); }

ll reduce(ll a,ll m)
{
  a%=m;
  a+=m;
  a%=m;
  return a;
}

ll Extended_gcd(ll a,ll b,ll& x,ll& y)
{
  if(a==0)
  {
    x=0;
    y=1;
    return b;
  }
  else
  {
    ll x1,y1;
    ll g=Extended_gcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return g;
  }
}

bool leap(ll y)
{
  if(y%400==0) return true;
  if((y%4==0)&&(y%100!=0)) return true;
  return false;
}

ll isprime(ll n)
{
  if(n==1) return false;
  if(n==2) return true;
  for(int i=2;i*i<=n;i++)
  {
    if(n%i==0) return false;
  }
  return true;
}

bool prime[2000010];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));
    prime[1]=false;
    for (int p=2; p*p<=2000001; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=2000001; i += p)
                prime[i] = false;
        }
    }
}

// vector<ll> prime_vec[1000010];
// void modified_SieveOfEratosthenes()
// {
//     //prime[1]=false;
//     for (int p=2; p*p<=1000001; p++)
//     {
//         if (prime_vec[p].size()==0)
//         {
//             for (int i=p*2; i<=1000001; i += p)
//                 prime_vec[i].pb(p);
//         }
//     }
// }

////*** Various Exponentiation Functions ***////

ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}

// ll result[1000010];
// ll tempo[1000010];
// ll per[1000010];
//
//
// void permutation_exp(ll n,ll x)
// {
//   fr(o,1,n)
//   {
//     result[o]=o;
//   }
//
//   while(x>0)
//   {
//     if(x&1)
//     {
//       fr(o,1,n)
//       {
//         tempo[o]=result[o];
//       }
//
//       fr(o,1,n)
//       {
//         result[o]=tempo[per[o]];
//       }
//     }
//
//     fr(o,1,n)
//     {
//       tempo[o]=per[o];
//     }
//
//     fr(o,1,n)
//     {
//       per[o]=tempo[tempo[o]];
//     }
//     x>>=1;
//   }
// }

ll len;
ll ultimate[110][110];

void matrix_exp(ll arr[100][110],ll n)
{
  //ll len=4;
  ll res[110][110];
  rep(o,len)
  {
    rep(p,len)
    {
      if(o!=p)
      res[o][p]=0;
      else
      res[o][p]=1;
    }
  }

  ll temp[110][110];

  while(n)
  {
    if(n&1)
    {
      rep(x,len)
      {
        rep(y,len)
        {
          temp[x][y]=0;
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          fr(z,0,len-1)
          {
            temp[i][j]+=reduce(res[i][z]*arr[z][j],mod);
          }
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          res[i][j]=reduce(temp[i][j],mod);
        }
      }
    }

    rep(x,len)
    {
      rep(y,len)
      {
        temp[x][y]=0;
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        fr(z,0,len-1)
        {
          temp[i][j]+=reduce(arr[i][z]*arr[z][j],mod);
          temp[i][j]%=mod;
        }
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        arr[i][j]=reduce(temp[i][j],mod);
      }
    }

    n/=2;
  }

  fr(i,0,len-1)
  {
    fr(j,0,len-1)
    {
      ultimate[i][j]=reduce(res[i][j],mod);
    }
  }
}

ll modpow(ll a, ll b,ll x)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%x;
        a = (a * a)%x;
        b >>= 1;
    }
    return res;
}

////*** End of Various Exponentiation Functions ***////

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
        // Update y and x
        y = x - q * y;
        x = t;
    }
    // Make x positive
    if (x < 0)
       x += m0;
    return x;
}

ll int_sqrt(ll h)
{
  ll g=(ll)sqrt(h);
  g++;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  return -1;
}

ll lpf[1000001] = {};

void precompute()
{
  fr(i,2,1000000)
  {
    if(!lpf[i])
    {
      for(ll j=i;j<=1000000;j+=i)
      {
        if(!lpf[j])
        lpf[j]=i;
      }
    }
  }
}

ll fact[2000010];

void compute_fact()
{
  fact[0]=1;
  fr(o,1,2000004)
  {
    fact[o]=(fact[o-1]*o)%mod;
  }
}

ll ncr_mod(ll n,ll r)
{
  if(r==0||n==r) return 1;
  else return (((fact[n]*modInverse(fact[r],mod))%mod)*modInverse(fact[n-r],mod))%mod;
}

ll f(ll x)
{
  ll total=0;
  return total;
}

ll ternary_search(ll l, ll r)
{              //set the error limit here
    while (r - l > 10)
    {
        ll m1 = l + (r - l) / 3;
        ll m2 = r - (r - l) / 3;
        ll f1 = f(m1);      //evaluates the function at m1
        ll f2 = f(m2);      //evaluates the function at m2
        if (f1 > f2)
            l = m1;
        else
            r = m2;
    }
    ll mino=f(l);
    ll mino_x=l;

    fr(o,l,r)
    {
      if(f(o)<mino)
      {
        mino_x=o;
        mino=f(o);
      }
    }
    return f(mino_x);
}

// ll tree[2000010];
// void build(ll* a,ll v,ll tl,ll tr)
// {
//   if(tl==tr)
//   {
//     tree[v]=((a[tl]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     build(a,v*2,tl,tm);
//     build(a,v*2+1,tm+1,tr);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
// ll query(ll v,ll tl,ll tr,ll l,ll r)
// {
//   if(l>r) return 0;
//   if(l==tl&&r==tr) return tree[v];
//   ll tm=(tl+tr)/2;
//   return query(v*2,tl,tm,l,minim(r,tm))+query(v*2+1,tm+1,tr,maxim(l,tm+1),r);
// }
//
//
// void update(ll v,ll tl,ll tr,ll pos,ll new_val)
// {
//   if(tl==tr)
//   {
//     tree[v]=((arr[pos]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     if(pos<=tm) update(v*2,tl,tm,pos,new_val);
//     else update(v*2+1,tm+1,tr,pos,new_val);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
//
// ll find_kth(ll v,ll tl,ll tr,ll k)
// {
//   if(k>tree[v]) return -1;
//   if(tl==tr) return tl;
//   ll tm=(tl+tr)/2;
//   if(tree[v*2]>=k) return find_kth(v*2,tl,tm,k);
//   else return find_kth(v*2+1,tm+1,tr,k-tree[v*2]);
// }

ll far[1000010];
ll farsum[1000010];

ll func(ll x)
{
  return (x*(x+1))/2;
}

ll bs(ll low,ll high,ll target)
{
  while(low+4<high)
  {
    ll mid=(low+high)/2;
    //increasing function with inclusion
    if(func(mid)<target)
    {
      low=mid;
    }
    else
    {
      high=mid-1;
    }
  }

  frr(o,high,low)
  {
    if(func(o)<target) return o;
  }

  return -1;
}

ll lpfx(ll x)
{
  if(x%2==0) return 2;
  else
  {
    for(int z=3;z*z<=x;z+=2)
    {
      if(x%z==0) return z;
    }
  }
  return x;
}

ll fz(ll n)
{
  ll o=1;
  while(o<=n)
  {
    o*=2;
  }
  return o;
}

ll arr[1000010];
map<ll,ll> mx;
map<ll,string> vx;

int main()
{
  fast;

  #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif

  c(n);
  carr(arr,n);
  rep(o,n)
  {
    if(mx.find(arr[o]-1)!=mx.end())
    {
        mx[arr[o]]=mx[arr[o]-1]+1;
    }
    else
    {
      if(mx.find(arr[o])==mx.end())
      {
        mx[arr[o]]=1;
      }
    }
  }

  ll maxo=0;
  rep(o,n)
  {
    maxo=maxim(maxo,mx[arr[o]]);
  }

  // debug(maxo);
  // rep(o,n)
  // {
  //   cout<<mx[arr[o]]<<" ";
  // }
  // cout<<endl;

  repr(o,n)
  {
    if(mx[arr[o]]==maxo)
    {
      cout<<maxo<<endl;
      ll p=arr[o];
      string ans="";
      ll index=o;
      while(1)
      {
        if(arr[index]==p)
        {
          ostringstream ssd;
          ssd<<index+1;
          ans=ssd.str()+" "+ans;
          p--;
        }
        index--;
        if(index==-1) break;
        if(p==arr[o]-maxo) break;
      }
      cout<<ans<<endl;
      break;
    }
  }
  return 0;
}


////////////////<------------- Xorcestor_X -------------->////////////////
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>
#include <utility>
#include <set>
#include <deque>
#include <string>

using namespace std;
#define endl "\n"
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 1e16
#define mod 1000000007
#define mod2 998244353
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) fr(i,0,n-1) cin>>arr[i]
#define carr2(arr,n,m) fr(i,0,n-1) fr(j,0,m-1) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define debugx(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debugx("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
const ll N = 105;
typedef ll mt[N][N];

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b) { return b==0 ? a : gcd(b, a%b); }

ll reduce(ll a,ll m)
{
  a%=m;
  a+=m;
  a%=m;
  return a;
}

ll Extended_gcd(ll a,ll b,ll& x,ll& y)
{
  if(a==0)
  {
    x=0;
    y=1;
    return b;
  }
  else
  {
    ll x1,y1;
    ll g=Extended_gcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return g;
  }
}

bool leap(ll y)
{
  if(y%400==0) return true;
  if((y%4==0)&&(y%100!=0)) return true;
  return false;
}

ll isprime(ll n)
{
  if(n==1) return false;
  if(n==2) return true;
  for(int i=2;i*i<=n;i++)
  {
    if(n%i==0) return false;
  }
  return true;
}

bool prime[2000010];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));
    prime[1]=false;
    for (int p=2; p*p<=2000001; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=2000001; i += p)
                prime[i] = false;
        }
    }
}

// vector<ll> prime_vec[1000010];
// void modified_SieveOfEratosthenes()
// {
//     //prime[1]=false;
//     for (int p=2; p*p<=1000001; p++)
//     {
//         if (prime_vec[p].size()==0)
//         {
//             for (int i=p*2; i<=1000001; i += p)
//                 prime_vec[i].pb(p);
//         }
//     }
// }

////*** Various Exponentiation Functions ***////

ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}

// ll result[1000010];
// ll tempo[1000010];
// ll per[1000010];
//
//
// void permutation_exp(ll n,ll x)
// {
//   fr(o,1,n)
//   {
//     result[o]=o;
//   }
//
//   while(x>0)
//   {
//     if(x&1)
//     {
//       fr(o,1,n)
//       {
//         tempo[o]=result[o];
//       }
//
//       fr(o,1,n)
//       {
//         result[o]=tempo[per[o]];
//       }
//     }
//
//     fr(o,1,n)
//     {
//       tempo[o]=per[o];
//     }
//
//     fr(o,1,n)
//     {
//       per[o]=tempo[tempo[o]];
//     }
//     x>>=1;
//   }
// }

ll len;
ll ultimate[110][110];

void matrix_exp(ll arr[100][110],ll n)
{
  //ll len=4;
  ll res[110][110];
  rep(o,len)
  {
    rep(p,len)
    {
      if(o!=p)
      res[o][p]=0;
      else
      res[o][p]=1;
    }
  }

  ll temp[110][110];

  while(n)
  {
    if(n&1)
    {
      rep(x,len)
      {
        rep(y,len)
        {
          temp[x][y]=0;
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          fr(z,0,len-1)
          {
            temp[i][j]+=reduce(res[i][z]*arr[z][j],mod);
          }
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          res[i][j]=reduce(temp[i][j],mod);
        }
      }
    }

    rep(x,len)
    {
      rep(y,len)
      {
        temp[x][y]=0;
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        fr(z,0,len-1)
        {
          temp[i][j]+=reduce(arr[i][z]*arr[z][j],mod);
          temp[i][j]%=mod;
        }
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        arr[i][j]=reduce(temp[i][j],mod);
      }
    }

    n/=2;
  }

  fr(i,0,len-1)
  {
    fr(j,0,len-1)
    {
      ultimate[i][j]=reduce(res[i][j],mod);
    }
  }
}

ll modpow(ll a, ll b,ll x)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%x;
        a = (a * a)%x;
        b >>= 1;
    }
    return res;
}

////*** End of Various Exponentiation Functions ***////

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
        // Update y and x
        y = x - q * y;
        x = t;
    }
    // Make x positive
    if (x < 0)
       x += m0;
    return x;
}

ll int_sqrt(ll h)
{
  ll g=(ll)sqrt(h);
  g++;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  return -1;
}

ll lpf[1000001] = {};

void precompute()
{
  fr(i,2,1000000)
  {
    if(!lpf[i])
    {
      for(ll j=i;j<=1000000;j+=i)
      {
        if(!lpf[j])
        lpf[j]=i;
      }
    }
  }
}

ll fact[2000010];

void compute_fact()
{
  fact[0]=1;
  fr(o,1,2000004)
  {
    fact[o]=(fact[o-1]*o)%mod;
  }
}

ll ncr_mod(ll n,ll r)
{
  if(r==0||n==r) return 1;
  else return (((fact[n]*modInverse(fact[r],mod))%mod)*modInverse(fact[n-r],mod))%mod;
}

ll f(ll x)
{
  ll total=0;
  return total;
}

ll ternary_search(ll l, ll r)
{              //set the error limit here
    while (r - l > 10)
    {
        ll m1 = l + (r - l) / 3;
        ll m2 = r - (r - l) / 3;
        ll f1 = f(m1);      //evaluates the function at m1
        ll f2 = f(m2);      //evaluates the function at m2
        if (f1 > f2)
            l = m1;
        else
            r = m2;
    }
    ll mino=f(l);
    ll mino_x=l;

    fr(o,l,r)
    {
      if(f(o)<mino)
      {
        mino_x=o;
        mino=f(o);
      }
    }
    return f(mino_x);
}

// ll tree[2000010];
// void build(ll* a,ll v,ll tl,ll tr)
// {
//   if(tl==tr)
//   {
//     tree[v]=((a[tl]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     build(a,v*2,tl,tm);
//     build(a,v*2+1,tm+1,tr);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
// ll query(ll v,ll tl,ll tr,ll l,ll r)
// {
//   if(l>r) return 0;
//   if(l==tl&&r==tr) return tree[v];
//   ll tm=(tl+tr)/2;
//   return query(v*2,tl,tm,l,minim(r,tm))+query(v*2+1,tm+1,tr,maxim(l,tm+1),r);
// }
//
//
// void update(ll v,ll tl,ll tr,ll pos,ll new_val)
// {
//   if(tl==tr)
//   {
//     tree[v]=((arr[pos]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     if(pos<=tm) update(v*2,tl,tm,pos,new_val);
//     else update(v*2+1,tm+1,tr,pos,new_val);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
//
// ll find_kth(ll v,ll tl,ll tr,ll k)
// {
//   if(k>tree[v]) return -1;
//   if(tl==tr) return tl;
//   ll tm=(tl+tr)/2;
//   if(tree[v*2]>=k) return find_kth(v*2,tl,tm,k);
//   else return find_kth(v*2+1,tm+1,tr,k-tree[v*2]);
// }

ll far[1000010];
ll farsum[1000010];

ll func(ll x)
{
  return (x*(x+1))/2;
}

ll bs(ll low,ll high,ll target)
{
  while(low+4<high)
  {
    ll mid=(low+high)/2;
    //increasing function with inclusion
    if(func(mid)<target)
    {
      low=mid;
    }
    else
    {
      high=mid-1;
    }
  }

  frr(o,high,low)
  {
    if(func(o)<target) return o;
  }

  return -1;
}

ll lpfx(ll x)
{
  if(x%2==0) return 2;
  else
  {
    for(int z=3;z*z<=x;z+=2)
    {
      if(x%z==0) return z;
    }
  }
  return x;
}

ll fz(ll n)
{
  ll o=1;
  while(o<=n)
  {
    o*=2;
  }
  return o;
}

ll arr[1000010];
map<ll,ll> mx;
map<ll,string> vx;

int main()
{
  fast;

  #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif

  c(n);
  carr(arr,n);
  rep(o,n)
  {
    if(mx.find(arr[o]-1)!=mx.end())
    {
        mx[arr[o]]=mx[arr[o]-1]+1;
    }
    else
    {
      if(mx.find(arr[o])==mx.end())
      {
        mx[arr[o]]=1;
      }
    }
  }

  ll maxo=0;
  rep(o,n)
  {
    maxo=maxim(maxo,mx[arr[o]]);
  }

  // debug(maxo);
  // rep(o,n)
  // {
  //   cout<<mx[arr[o]]<<" ";
  // }
  // cout<<endl;

  repr(o,n)
  {
    if(mx[arr[o]]==maxo)
    {
      cout<<maxo<<endl;
      ll p=arr[o];
      vector<ll> ans;
      ll index=o;
      while(1)
      {
        if(arr[index]==p)
        {
          ans.pb(index+1);
          p--;
        }
        index--;
        if(index==-1) break;
        if(p==arr[o]-maxo) break;
      }

      ll fg=ans.size();
      frr(p,fg-1,0)
      {
        cout<<ans[p]<<" ";
      }
      cout<<endl;
      break;
    }
  }
  return 0;
}


////////////////<------------- Xorcestor_X -------------->////////////////
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>
#include <utility>
#include <set>
#include <deque>
#include <string>

using namespace std;
#define endl "\n"
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 1e16
#define mod 1000000007
#define mod2 998244353
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) fr(i,0,n-1) cin>>arr[i]
#define carr2(arr,n,m) fr(i,0,n-1) fr(j,0,m-1) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define debugx(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debugx("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
const ll N = 105;
typedef ll mt[N][N];

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b) { return b==0 ? a : gcd(b, a%b); }

ll reduce(ll a,ll m)
{
  a%=m;
  a+=m;
  a%=m;
  return a;
}

ll Extended_gcd(ll a,ll b,ll& x,ll& y)
{
  if(a==0)
  {
    x=0;
    y=1;
    return b;
  }
  else
  {
    ll x1,y1;
    ll g=Extended_gcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return g;
  }
}

bool leap(ll y)
{
  if(y%400==0) return true;
  if((y%4==0)&&(y%100!=0)) return true;
  return false;
}

ll isprime(ll n)
{
  if(n==1) return false;
  if(n==2) return true;
  for(int i=2;i*i<=n;i++)
  {
    if(n%i==0) return false;
  }
  return true;
}

bool prime[2000010];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));
    prime[1]=false;
    for (int p=2; p*p<=2000001; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=2000001; i += p)
                prime[i] = false;
        }
    }
}

// vector<ll> prime_vec[1000010];
// void modified_SieveOfEratosthenes()
// {
//     //prime[1]=false;
//     for (int p=2; p*p<=1000001; p++)
//     {
//         if (prime_vec[p].size()==0)
//         {
//             for (int i=p*2; i<=1000001; i += p)
//                 prime_vec[i].pb(p);
//         }
//     }
// }

////*** Various Exponentiation Functions ***////

ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}

// ll result[1000010];
// ll tempo[1000010];
// ll per[1000010];
//
//
// void permutation_exp(ll n,ll x)
// {
//   fr(o,1,n)
//   {
//     result[o]=o;
//   }
//
//   while(x>0)
//   {
//     if(x&1)
//     {
//       fr(o,1,n)
//       {
//         tempo[o]=result[o];
//       }
//
//       fr(o,1,n)
//       {
//         result[o]=tempo[per[o]];
//       }
//     }
//
//     fr(o,1,n)
//     {
//       tempo[o]=per[o];
//     }
//
//     fr(o,1,n)
//     {
//       per[o]=tempo[tempo[o]];
//     }
//     x>>=1;
//   }
// }

ll len;
ll ultimate[110][110];

void matrix_exp(ll arr[100][110],ll n)
{
  //ll len=4;
  ll res[110][110];
  rep(o,len)
  {
    rep(p,len)
    {
      if(o!=p)
      res[o][p]=0;
      else
      res[o][p]=1;
    }
  }

  ll temp[110][110];

  while(n)
  {
    if(n&1)
    {
      rep(x,len)
      {
        rep(y,len)
        {
          temp[x][y]=0;
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          fr(z,0,len-1)
          {
            temp[i][j]+=reduce(res[i][z]*arr[z][j],mod);
          }
        }
      }

      fr(i,0,len-1)
      {
        fr(j,0,len-1)
        {
          res[i][j]=reduce(temp[i][j],mod);
        }
      }
    }

    rep(x,len)
    {
      rep(y,len)
      {
        temp[x][y]=0;
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        fr(z,0,len-1)
        {
          temp[i][j]+=reduce(arr[i][z]*arr[z][j],mod);
          temp[i][j]%=mod;
        }
      }
    }

    fr(i,0,len-1)
    {
      fr(j,0,len-1)
      {
        arr[i][j]=reduce(temp[i][j],mod);
      }
    }

    n/=2;
  }

  fr(i,0,len-1)
  {
    fr(j,0,len-1)
    {
      ultimate[i][j]=reduce(res[i][j],mod);
    }
  }
}

ll modpow(ll a, ll b,ll x)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%x;
        a = (a * a)%x;
        b >>= 1;
    }
    return res;
}

////*** End of Various Exponentiation Functions ***////

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
        // Update y and x
        y = x - q * y;
        x = t;
    }
    // Make x positive
    if (x < 0)
       x += m0;
    return x;
}

ll int_sqrt(ll h)
{
  ll g=(ll)sqrt(h);
  g++;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  g--;
  if(g*g==h) return g;
  return -1;
}

ll lpf[1000001] = {};

void precompute()
{
  fr(i,2,1000000)
  {
    if(!lpf[i])
    {
      for(ll j=i;j<=1000000;j+=i)
      {
        if(!lpf[j])
        lpf[j]=i;
      }
    }
  }
}

ll fact[2000010];

void compute_fact()
{
  fact[0]=1;
  fr(o,1,2000004)
  {
    fact[o]=(fact[o-1]*o)%mod;
  }
}

ll ncr_mod(ll n,ll r)
{
  if(r==0||n==r) return 1;
  else return (((fact[n]*modInverse(fact[r],mod))%mod)*modInverse(fact[n-r],mod))%mod;
}

ll f(ll x)
{
  ll total=0;
  return total;
}

ll ternary_search(ll l, ll r)
{              //set the error limit here
    while (r - l > 10)
    {
        ll m1 = l + (r - l) / 3;
        ll m2 = r - (r - l) / 3;
        ll f1 = f(m1);      //evaluates the function at m1
        ll f2 = f(m2);      //evaluates the function at m2
        if (f1 > f2)
            l = m1;
        else
            r = m2;
    }
    ll mino=f(l);
    ll mino_x=l;

    fr(o,l,r)
    {
      if(f(o)<mino)
      {
        mino_x=o;
        mino=f(o);
      }
    }
    return f(mino_x);
}

// ll tree[2000010];
// void build(ll* a,ll v,ll tl,ll tr)
// {
//   if(tl==tr)
//   {
//     tree[v]=((a[tl]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     build(a,v*2,tl,tm);
//     build(a,v*2+1,tm+1,tr);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
// ll query(ll v,ll tl,ll tr,ll l,ll r)
// {
//   if(l>r) return 0;
//   if(l==tl&&r==tr) return tree[v];
//   ll tm=(tl+tr)/2;
//   return query(v*2,tl,tm,l,minim(r,tm))+query(v*2+1,tm+1,tr,maxim(l,tm+1),r);
// }
//
//
// void update(ll v,ll tl,ll tr,ll pos,ll new_val)
// {
//   if(tl==tr)
//   {
//     tree[v]=((arr[pos]==x)?1:0);
//   }
//   else
//   {
//     ll tm=(tl+tr)/2;
//     if(pos<=tm) update(v*2,tl,tm,pos,new_val);
//     else update(v*2+1,tm+1,tr,pos,new_val);
//     tree[v]=tree[v*2]+tree[v*2+1];
//   }
// }
//
//
// ll find_kth(ll v,ll tl,ll tr,ll k)
// {
//   if(k>tree[v]) return -1;
//   if(tl==tr) return tl;
//   ll tm=(tl+tr)/2;
//   if(tree[v*2]>=k) return find_kth(v*2,tl,tm,k);
//   else return find_kth(v*2+1,tm+1,tr,k-tree[v*2]);
// }

ll far[1000010];
ll farsum[1000010];

ll func(ll x)
{
  return (x*(x+1))/2;
}

ll bs(ll low,ll high,ll target)
{
  while(low+4<high)
  {
    ll mid=(low+high)/2;
    //increasing function with inclusion
    if(func(mid)<target)
    {
      low=mid;
    }
    else
    {
      high=mid-1;
    }
  }

  frr(o,high,low)
  {
    if(func(o)<target) return o;
  }

  return -1;
}

ll lpfx(ll x)
{
  if(x%2==0) return 2;
  else
  {
    for(int z=3;z*z<=x;z+=2)
    {
      if(x%z==0) return z;
    }
  }
  return x;
}

ll fz(ll n)
{
  ll o=1;
  while(o<=n)
  {
    o*=2;
  }
  return o;
}

ll arr[1000010];
map<ll,ll> mx;
map<ll,string> vx;

int main()
{
  fast;

  #ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
  #endif

  c(n);
  carr(arr,n);
  rep(o,n)
  {
    if(mx.find(arr[o]-1)!=mx.end())
    {
      if(mx[arr[o]-1]+1>mx[arr[o]])
      {
        ostringstream str1;
        str1<<o+1;
        string f=vx[arr[o]-1];
        f+=" "+str1.str();
        // f.pb(o+1);
        vx[arr[o]]=f;
        mx[arr[o]]=mx[arr[o]-1]+1;
      }
    }
    else
    {
      if(mx.find(arr[o])==mx.end())
      {
        mx[arr[o]]=1;
        // vector<ll> temp;
        // temp.pb(o+1);
        ostringstream str1;
        str1<<o+1;
        vx[arr[o]]=str1.str();
      }
    }
  }

  ll maxo=0;
  rep(o,n)
  {
    maxo=maxim(maxo,mx[arr[o]]);
  }

  // debug(maxo);
  // rep(o,n)
  // {
  //   cout<<mx[arr[o]]<<" ";
  // }
  // cout<<endl;

  rep(o,n)
  {
    if(mx[arr[o]]==maxo)
    {
      cout<<maxo<<endl;
      cout<<vx[arr[o]]<<endl;
      break;
    }
  }
  return 0;
}