#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll n;
	cin>>n;
	vll a;
//	input(a,n);
	um<ll,ll> dp;
	ll ans=0,last,x;
	rep(i,0,n-1,1)
	{

		cin>>x;
		a.pb(x);
		dp[x]=dp[x-1]+1;
	//	parent[i]=pos[a[i]-1];
		//pos[a[i]]=i;
		if(dp[x]>ans)
		{
			last=x;
			ans=dp[x];
		}
	}
	cout<<ans<<"\n";
	ll val=last-ans+1;
//	db(last,a[last]);
	rep(i,0,n-1,1)
	if(a[i]==val)
	{
	cout<<i+1<<" ";
	val++;
	if(val>last)
	return 0;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll n;
	cin>>n;
	vll a(n);
	input(a,n);
	um<ll,ll> dp;
//	vll parent(n);
//	pll p;
	ll ans=0,last;
	rep(i,0,n-1,1)
	{
		dp[a[i]]=dp[a[i]-1]+1;
	//	parent[i]=pos[a[i]-1];
		//pos[a[i]]=i;
		if(dp[a[i]]>ans)
		{
			last=i;
			ans=dp[a[i]];
		}
	}
	cout<<ans<<"\n";
	ll val=a[last]-ans+1;
	rep(i,0,n-1,1)
	if(a[i]==val)
	{
	cout<<i+1<<" ";
	val++;
	if(val==a[i])
	break;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

umll dp,pos,parent;

int main()
{
	fastIO
	ll n;
	cin>>n;
	vll a(n);
	input(a,n);
	pll p;
	ll ans=0,last;
	rep(i,0,n-1,1)
	{
		dp[a[i]]=dp[a[i]-1]+1;
		parent[i]=pos[a[i]-1];
	//	db(parent[i],i);
		pos[a[i]]=i;
		if(dp[a[i]]>ans)
		{
			last=i;
			ans=dp[a[i]];
		}
	}
	cout<<ans<<"\n";
	vll v;
	rep(i,0,ans-1,1)
	{
	v.pb(last+1);
	last=parent[last];
	}
	reverse(all(v));
	show(v,v.size());
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll n;
	cin>>n;
	vll a(n);
	input(a,n);
	um<ll,ll> dp;
	umll pos;
	vll parent(n);
	pll p;
	ll ans=0,last;
	rep(i,0,n-1,1)
	{
		dp[a[i]]=dp[a[i]-1]+1;
		parent[i]=pos[a[i]-1];
	//	db(parent[i],i);
		pos[a[i]]=i;
		if(dp[a[i]]>ans)
		{
			last=i;
			ans=dp[a[i]];
		}
	}
	cout<<ans<<"\n";
	vll v;
	rep(i,0,ans-1,1)
	{
	v.pb(last+1);
	last=parent[last];
	}
	reverse(all(v));
	show(v,v.size());
	return 0;
}


// start of CP 2.0
#include <bits/stdc++.h>

//____By:sirjan13____

#define int long long
#define ld long double
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define show(a) for(int i=0;i<a.size();i++) cout<<a[i]<<" ";
#define fi first
#define se second
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define pb push_back
#define pi pair<int,int>
#define si set<int>
#define sll set<ll>
#define pll pair<ll, ll>
#define sci(x) scanf("%d",&x)
#define scs(x)  scanf("%s", x)
#define scll(x) scanf("%I64d",&x)
#define all(v) v.begin(),v.end()
#define sot(v) sort(v.begin(), v.end())
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
#define mp make_pair
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);
#define PI 3.1415926535
#define long_zero 0ll
#define long_one 1ll

inline int sbt(int x){return __builtin_popcount(x);}

using namespace std;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif
int n;
#define N 200013
vi a;
int maxi = 0, en;
map<int, int> dp;

int32_t main() {
    fast_io()
    cin >> n;
    dp[0] = 0;
    a.pb(0);
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        a.pb(x);
        dp[x] = dp[x - 1] + 1;
        if(dp[x] > maxi) {
            maxi = dp[x];
            en = x;
        }
    }
    cout << maxi << endl;
    int st = en - maxi + 1;
    int done = 0;
    int k = maxi;
    for(int i = 1; i <= n; i++) {
        if(done == k) {
            return 0;
        }
        if(a[i] == st) {
            done++;
            st++;
            cout << i << ' ';
        }
    }

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll n;
	cin>>n;
	vll a(n);
	input(a,n);
	um<ll,ll> dp;
	ll ans=0,last;
	rep(i,0,n-1,1)
	{
		dp[a[i]]=dp[a[i]-1]+1;
	//	parent[i]=pos[a[i]-1];
		//pos[a[i]]=i;
		if(dp[a[i]]>ans)
		{
			last=i;
			ans=dp[a[i]];
		}
	}
	cout<<ans<<"\n";
	ll val=a[last]-ans+1;
//	db(last,a[last]);
	rep(i,0,n-1,1)
	if(a[i]==val)
	{
	cout<<i+1<<" ";
	val++;
	if(val>a[last])
	return 0;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

umll dp,pos,parent;
ll n,ans,last;
vll a(200006),v;

int main()
{
	fastIO
//	ll n;
	cin>>n;
//	vll a(n);
	input(a,n);
//	pll p;
//	ll ans=0,last;
	rep(i,0,n-1,1)
	{
		dp[a[i]]=dp[a[i]-1]+1;
		parent[i]=pos[a[i]-1];
	//	db(parent[i],i);
		pos[a[i]]=i;
		if(dp[a[i]]>ans)
		{
			last=i;
			ans=dp[a[i]];
		}
	}
	cout<<ans<<"\n";
//	vll v;
	rep(i,0,ans-1,1)
	{
	v.pb(last+1);
	last=parent[last];
	}
	reverse(all(v));
	show(v,v.size());
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

umll dp;
ll ans,last,x,val;
vll a;

int main()
{
	fastIO
	ll n;
	cin>>n;
	dp[0]=0;
	rep(i,0,n-1,1)
	{
		cin>>x;
		a.pb(x);
		dp[x]=dp[x-1]+1;
	//	parent[i]=pos[a[i]-1];
		//pos[a[i]]=i;
		if(dp[x]>ans)
		{
			last=x;
			ans=dp[x];
		}
	}
	cout<<ans<<"\n";
	val=last-ans+1;
//	db(last,a[last]);
	rep(i,0,n-1,1)
	if(a[i]==val)
	{
	cout<<i+1<<" ";
	val++;
	if(val>last)
	return 0;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll n;
	cin>>n;
	vll a(n);
	input(a,n);
	um<ll,ll> dp;
	umll idx,parent,pos;
	pll p;
	ll ans=0,last;
	rep(i,0,n-1,1)
	{
		dp[a[i]]=dp[a[i]-1]+1;
		parent[i]=pos[a[i]-1];
	//	db(parent[i],i);
		pos[a[i]]=i;
		if(dp[a[i]]>ans)
		{
			last=i;
			ans=dp[a[i]];
		}
	}
	cout<<ans<<"\n";
	vll v;
	rep(i,0,ans-1,1)
	{
	v.pb(a[last]);
	last=parent[last];
	}
	reverse(all(v));
	show(v,v.size());
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll n;
	cin>>n;
	vll a;
//	input(a,n);
	um<ll,ll> dp;
	ll ans=0,last,x;
	rep(i,0,n-1,1)
	{

		cin>>x;
		a.pb(x);
		dp[x]=dp[x-1]+1;
	//	parent[i]=pos[a[i]-1];
		//pos[a[i]]=i;
		if(dp[x]>ans)
		{
			last=i;
			ans=dp[x];
		}
	}
	cout<<ans<<"\n";
	ll val=a[last]-ans+1;
//	db(last,a[last]);
	rep(i,0,n-1,1)
	if(a[i]==val)
	{
	cout<<i+1<<" ";
	val++;
	if(val>a[last])
	break;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	unordered_map<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m[x].size() < m[x-1].size()+1) {
			m[x-1].push_back({x, i});
			m[x] = move(m[x-1]);
		}
		//m.erase(x-1);
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	//unordered_map<int, vector<pair<int, int>>> m;
	__gnu_pbds::cc_hash_table<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m[x].size() < m[x-1].size()+1) {
			m[x-1].push_back({x, i});
			m[x] = move(m[x-1]);
		}
		m.erase(x-1);
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	unordered_map<int, vector<pair<int, int>>> m;
	//__gnu_pbds::cc_hash_table<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m[x].size() < m[x-1].size()+1) {
			m[x-1].push_back({x, i});
			m[x] = move(m[x-1]);
		}
		m.erase(x-1);
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	map<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m[x].size() < m[x-1].size()+1) {
			m[x-1].emplace_back(x, i);
			m[x] = move(m[x-1]);
		}
		m.erase(x-1);
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

	int n; cin >> n;
	unordered_map<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m.count(x-1)) {
			m[x-1].push_back({x, i});
			m[x] = move(m[x-1]);
			m.erase(x-1);
		}
		else {
			m[x] = {{x, i}};
		}
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

	int n; cin >> n;
	unordered_map<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m[x].size() < m[x-1].size()+1) {
			m[x-1].push_back({x, i});
			m[x] = move(m[x-1]);
		}
		m.erase(x-1);
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	__gnu_pbds::cc_hash_table<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m[x].size() < m[x-1].size()+1) {
			m[x-1].emplace_back(x, i);
			m[x] = move(m[x-1]);
		}
		m.erase(x-1);
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	__gnu_pbds::tree<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m[x].size() < m[x-1].size()+1) {
			m[x-1].emplace_back(x, i);
			m[x] = move(m[x-1]);
		}
		m.erase(x-1);
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	//unordered_map<int, vector<pair<int, int>>> m;
	__gnu_pbds::gp_hash_table<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m[x].size() < m[x-1].size()+1) {
			m[x-1].push_back({x, i});
			m[x] = move(m[x-1]);
		}
		m.erase(x-1);
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	unordered_map<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m[x].size() < m[x-1].size()+1) {
			m[x-1].push_back({x, i});
			m[x] = move(m[x-1]);
		}
		m.erase(x-1);
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	unordered_map<int, vector<pair<int, int>>> m;

	for(int i = 1; i <= n; i ++) {
		int x; cin >> x;
		if(m[x].size() < m[x-1].size()+1) {
			m[x-1].emplace_back(x, i);
			m[x] = move(m[x-1]);
		}
		m.erase(x-1);
	}

	auto it = max_element(m.begin(), m.end(), [](auto&& l, auto&& r){return l.second.size() < r.second.size();});

	cout << it->second.size() << endl;
	for(auto&& x : it->second) cout << x.second << " ";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define f(n) for(int i=0; i<n; i++)
typedef long long int ll;
ll inf=numeric_limits<ll>::max();

int main()
{
    ll n; cin>>n;
    vector<ll> ar(n); f(n)cin>>ar[i];
    unordered_map<ll, set<ll>> occurencesOfNum;
    for(ll i=0; i<n; i++)
    {
        occurencesOfNum[ar[i]].insert(i);
    }
    // for(auto x: occurencesOfNum)
    // {
    //     cout<<"num  "<<x.first<<endl;
    //     for(auto y: x.second)
    //     {
    //         cout<<y<<" ";
    //     }cout<<endl;
    // }

    vector<ll> answer;
    for(ll i=0; i<n; i++)
    {
        ll x=i;
        vector<ll> temp; temp.push_back(x);
        temp.clear();
        while(occurencesOfNum[ar[x]+1].lower_bound(x+1)!=occurencesOfNum[ar[x]+1].end())
        {
            x=(*occurencesOfNum[ar[x]+1].lower_bound(x+1));
            // cout<<x<<" "<<ar[x]+1<<endl;
            occurencesOfNum[ar[x]].clear();
            temp.push_back(x);
        }

        // for(auto d: temp)
        // {
        //     cout<<d<<" ";
        // }cout<<endl;
        if(temp.size()>answer.size())
        {
            answer=temp;
        }
    }
    cout<<answer.size()<<'\n';
    for(auto d: answer) cout<<d+1<<" ";
}

/*

7
3 3 4 7 5 6 8

*/


#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define f(n) for(int i=0; i<n; i++)
typedef long long int ll;

ll inf=numeric_limits<ll>::max();
ll findMaxLen(ll ind, vector<ll>& ar, map<ll, set<ll>>& occurencesOfNum, vector<ll>& maxLenForInd)
{
    if(ind==maxLenForInd.size()-1) // pokud jsme na poslednim prvku
    {
        return(1);
    }

    if(maxLenForInd[ind]!=-1)
    {
        return(maxLenForInd[ind]);
    }

    ll maxl=1;
    if(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ll res=findMaxLen(*occurencesOfNum[ar[ind]+1].lower_bound(ind+1), ar, occurencesOfNum, maxLenForInd)+1;
        maxl=max(maxl, res);
    }

    maxLenForInd[ind]=maxl;
    return(maxl);
}

int main()
{
    ll n; cin>>n;
    vector<ll> ar(n); f(n)cin>>ar[i];
    map<ll, set<ll>> occurencesOfNum;
    if(n==1)
    {
        cout<<1<<'\n'<<1;
        return(0);
    }
    for(ll i=0; i<n; i++)
    {
        occurencesOfNum[ar[i]].insert(i);
    }
    vector<ll> maxLenForInd(n,-1);
    for(ll i=0; i<n; i++)
    {
        findMaxLen(i, ar, occurencesOfNum, maxLenForInd);
    }

    cout<<*max_element(all(maxLenForInd))<<'\n';
    ll ind=distance(maxLenForInd.begin(), max_element(all(maxLenForInd)));
    cout<<ind+1<<' ';
    while(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ind=*(occurencesOfNum[ar[ind]+1].lower_bound(ind+1));
        cout<<ind+1<<' ';
    }
    // for(auto x: occurencesOfNum)
    // {
    //     cout<<"num  "<<x.first<<endl;
    //     for(auto y: x.second)
    //     {
    //         cout<<y<<" ";
    //     }cout<<endl;
    // }

}

/*

7
3 3 4 7 5 6 8

*/


#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define f(n) for(int i=0; i<n; i++)
typedef long long int ll;

ll inf=numeric_limits<ll>::max();
ll findMaxLen(ll ind, vector<ll>& ar, unordered_map<ll, set<ll>>& occurencesOfNum, vector<ll>& maxLenForInd)
{
    if(ind==maxLenForInd.size()-1) // pokud jsme na poslednim prvku
    {
        return(1);
    }

    if(maxLenForInd[ind]!=-1)
    {
        return(maxLenForInd[ind]);
    }

    ll maxl=1;
    if(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ll res=findMaxLen(*occurencesOfNum[ar[ind]+1].lower_bound(ind+1), ar, occurencesOfNum, maxLenForInd)+1;
        maxl=max(maxl, res);
    }

    maxLenForInd[ind]=maxl;
    return(maxl);
}

int main()
{
    ll n; cin>>n;
    vector<ll> ar(n); f(n)cin>>ar[i];
    map<ll, set<ll>> occurencesOfNum;
    if(n==1)
    {
        cout<<1<<'\n'<<1;
        return(0);
    }
    for(ll i=0; i<n; i++)
    {
        occurencesOfNum[ar[i]].insert(i);
    }
    vector<ll> maxLenForInd(n,-1);
    for(ll i=0; i<n; i++)
    {
        findMaxLen(i, ar, occurencesOfNum, maxLenForInd);
    }

    cout<<*max_element(all(maxLenForInd))<<'\n';
    ll ind=distance(maxLenForInd.begin(), max_element(all(maxLenForInd)));
    cout<<ind+1<<' ';
    while(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ind=*(occurencesOfNum[ar[ind]+1].lower_bound(ind+1));
        cout<<ind+1<<' ';
    }
    // for(auto x: occurencesOfNum)
    // {
    //     cout<<"num  "<<x.first<<endl;
    //     for(auto y: x.second)
    //     {
    //         cout<<y<<" ";
    //     }cout<<endl;
    // }

}

/*

7
3 3 4 7 5 6 8

*/


#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define f(n) for(int i=0; i<n; i++)
typedef long long int ll;

ll inf=numeric_limits<ll>::max();
ll findMaxLen(ll ind, vector<ll>& ar, unordered_map<ll, set<ll>>& occurencesOfNum, vector<ll>& maxLenForInd)
{
    if(ind==maxLenForInd.size()-1) // pokud jsme na poslednim prvku
    {
        return(1);
    }

    if(maxLenForInd[ind]!=-1)
    {
        return(maxLenForInd[ind]); }

    ll maxl=1;
    if(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ll res=findMaxLen(*occurencesOfNum[ar[ind]+1].lower_bound(ind+1), ar, occurencesOfNum, maxLenForInd)+1;
        maxl=max(maxl, res);
    }

    maxLenForInd[ind]=maxl;
    return(maxl);
}

int main()
{
    ll n; cin>>n;
    vector<ll> ar(n); f(n)cin>>ar[i];
    unordered_map<ll, set<ll>> occurencesOfNum;
    for(ll i=0; i<n; i++)
    {
        occurencesOfNum[ar[i]].insert(i);
    }
    vector<ll> maxLenForInd(n,-1);
    findMaxLen(0, ar, occurencesOfNum, maxLenForInd);

    cout<<*max_element(all(maxLenForInd))<<'\n';
    ll ind=distance(maxLenForInd.begin(), max_element(all(maxLenForInd)));
    cout<<ind+1<<' ';
    while(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ind=*(occurencesOfNum[ar[ind]+1].lower_bound(ind+1));
        cout<<ind+1<<' ';
    }
    // for(auto x: occurencesOfNum)
    // {
    //     cout<<"num  "<<x.first<<endl;
    //     for(auto y: x.second)
    //     {
    //         cout<<y<<" ";
    //     }cout<<endl;
    // }

}

/*

7
3 3 4 7 5 6 8

*/


#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define f(n) for(int i=0; i<n; i++)
typedef long long int ll;
ll inf=numeric_limits<ll>::max();

int main()
{
    ll n; cin>>n;
    vector<ll> ar(n); f(n)cin>>ar[i];
    unordered_map<ll, set<ll>> occurencesOfNum;
    for(ll i=0; i<n; i++)
    {
        occurencesOfNum[ar[i]].insert(i);
    }
    // for(auto x: occurencesOfNum)
    // {
    //     cout<<"num  "<<x.first<<endl;
    //     for(auto y: x.second)
    //     {
    //         cout<<y<<" ";
    //     }cout<<endl;
    // }

    vector<ll> answer;
    for(ll i=0; i<n; i++)
    {
        ll x=i;
        vector<ll> temp; temp.push_back(x);
        while(occurencesOfNum[ar[x]+1].lower_bound(x+1)!=occurencesOfNum[ar[x]+1].end())
        {
            x=(*occurencesOfNum[ar[x]+1].lower_bound(x+1));
            // cout<<x<<" "<<ar[x]+1<<endl;
            occurencesOfNum[ar[x]].clear();
            temp.push_back(x);
        }

        // for(auto d: temp)
        // {
        //     cout<<d<<" ";
        // }cout<<endl;
        if(temp.size()>answer.size())
        {
            answer=temp;
        }
    }
    cout<<answer.size()<<'\n';
    for(auto d: answer) cout<<d+1<<" ";
}

/*

7
3 3 4 7 5 6 8

*/


#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define f(n) for(int i=0; i<n; i++)
typedef long long int ll;

ll inf=numeric_limits<ll>::max();
ll findMaxLen(ll ind, vector<ll>& ar, unordered_map<ll, set<ll>>& occurencesOfNum, vector<ll>& maxLenForInd)
{
    if(ind==maxLenForInd.size()-1) // pokud jsme na poslednim prvku
    {
        return(1);
    }

    if(maxLenForInd[ind]!=-1)
    {
        return(maxLenForInd[ind]); }

    ll maxl=1;
    if(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ll res=findMaxLen(*occurencesOfNum[ar[ind]+1].lower_bound(ind+1), ar, occurencesOfNum, maxLenForInd)+1;
        maxl=max(maxl, res);
    }

    maxLenForInd[ind]=maxl;
    return(maxl);
}

int main()
{
    ll n; cin>>n;
    vector<ll> ar(n); f(n)cin>>ar[i];
    unordered_map<ll, set<ll>> occurencesOfNum;
    if(n==1)
    {
        cout<<1<<'\n'<<1;
        return(0);
    }
    for(ll i=0; i<n; i++)
    {
        occurencesOfNum[ar[i]].insert(i);
    }
    vector<ll> maxLenForInd(n,-1);
    for(ll i=0; i<n; i++)
    {
        findMaxLen(i, ar, occurencesOfNum, maxLenForInd);
    }

    cout<<*max_element(all(maxLenForInd))<<'\n';
    ll ind=distance(maxLenForInd.begin(), max_element(all(maxLenForInd)));
    cout<<ind+1<<' ';
    while(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ind=*(occurencesOfNum[ar[ind]+1].lower_bound(ind+1));
        cout<<ind+1<<' ';
    }
    // for(auto x: occurencesOfNum)
    // {
    //     cout<<"num  "<<x.first<<endl;
    //     for(auto y: x.second)
    //     {
    //         cout<<y<<" ";
    //     }cout<<endl;
    // }

}

/*

7
3 3 4 7 5 6 8

*/


#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define f(n) for(int i=0; i<n; i++)
typedef long long int ll;

ll inf=numeric_limits<ll>::max();
ll findMaxLen(ll ind, vector<ll>& ar, unordered_map<ll, set<ll>>& occurencesOfNum, vector<ll>& maxLenForInd)
{
    if(ind==maxLenForInd.size()-1) // pokud jsme na poslednim prvku
    {
        return(1);
    }

    if(maxLenForInd[ind]!=-1)
    {
        return(maxLenForInd[ind]); }

    ll maxl=1;
    if(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ll res=findMaxLen(*occurencesOfNum[ar[ind]+1].lower_bound(ind+1), ar, occurencesOfNum, maxLenForInd)+1;
        maxl=max(maxl, res);
    }

    maxLenForInd[ind]=maxl;
    return(maxl);
}

int main()
{
    ll n; cin>>n;
    vector<ll> ar(n); f(n)cin>>ar[i];
    unordered_map<ll, set<ll>> occurencesOfNum;
    if(n==1)
    {
        cout<<1<<'\n'<<1;
    }
    for(ll i=0; i<n; i++)
    {
        occurencesOfNum[ar[i]].insert(i);
    }
    vector<ll> maxLenForInd(n,-1);
    for(ll i=0; i<n; i++)
    {
        findMaxLen(i, ar, occurencesOfNum, maxLenForInd);
    }

    cout<<*max_element(all(maxLenForInd))<<'\n';
    ll ind=distance(maxLenForInd.begin(), max_element(all(maxLenForInd)));
    cout<<ind+1<<' ';
    while(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ind=*(occurencesOfNum[ar[ind]+1].lower_bound(ind+1));
        cout<<ind+1<<' ';
    }
    // for(auto x: occurencesOfNum)
    // {
    //     cout<<"num  "<<x.first<<endl;
    //     for(auto y: x.second)
    //     {
    //         cout<<y<<" ";
    //     }cout<<endl;
    // }

}

/*

7
3 3 4 7 5 6 8

*/


#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define f(n) for(int i=0; i<n; i++)
typedef long long int ll;
ll inf=numeric_limits<ll>::max();

int main()
{
    ll n; cin>>n;
    vector<ll> ar(n); f(n)cin>>ar[i];
    unordered_map<ll, set<ll>> occurencesOfNum;
    for(ll i=0; i<n; i++)
    {
        occurencesOfNum[ar[i]].insert(i);
    }
    // for(auto x: occurencesOfNum)
    // {
    //     cout<<"num  "<<x.first<<endl;
    //     for(auto y: x.second)
    //     {
    //         cout<<y<<" ";
    //     }cout<<endl;
    // }

    vector<ll> answer;
    for(ll i=0; i<n; i++)
    {
        ll x=i;
        vector<ll> temp; temp.push_back(x);
        while(occurencesOfNum[ar[x]+1].lower_bound(x+1)!=occurencesOfNum[ar[x]+1].end())
        {
            x=(*occurencesOfNum[ar[x]+1].lower_bound(x+1));
            // cout<<x<<" "<<ar[x]+1<<endl;
            // occurencesOfNum[ar[x]].clear();
            temp.push_back(x);
        }

        // for(auto d: temp)
        // {
        //     cout<<d<<" ";
        // }cout<<endl;
        if(temp.size()>answer.size())
        {
            answer=temp;
        }
    }
    cout<<answer.size()<<'\n';
    for(auto d: answer) cout<<d+1<<" ";
}

/*

7
3 3 4 7 5 6 8

*/


#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define f(n) for(int i=0; i<n; i++)
typedef long long int ll;

ll inf=numeric_limits<ll>::max();
ll findMaxLen(ll ind, vector<ll>& ar, unordered_map<ll, set<ll>>& occurencesOfNum, vector<ll>& maxLenForInd)
{
    if(ind==maxLenForInd.size()-1) // pokud jsme na poslednim prvku
    {
        return(1);
    }

    if(maxLenForInd[ind]!=-1)
    {
        return(maxLenForInd[ind]); }

    ll maxl=1;
    if(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ll res=findMaxLen(*occurencesOfNum[ar[ind]+1].lower_bound(ind+1), ar, occurencesOfNum, maxLenForInd)+1;
        maxl=max(maxl, res);
    }

    maxLenForInd[ind]=maxl;
    return(maxl);
}

int main()
{
    ll n; cin>>n;
    vector<ll> ar(n); f(n)cin>>ar[i];
    unordered_map<ll, set<ll>> occurencesOfNum;
    for(ll i=0; i<n; i++)
    {
        occurencesOfNum[ar[i]].insert(i);
    }
    vector<ll> maxLenForInd(n,-1);
    for(ll i=0; i<n; i++)
    {
        findMaxLen(i, ar, occurencesOfNum, maxLenForInd);
    }

    cout<<*max_element(all(maxLenForInd))<<'\n';
    ll ind=distance(maxLenForInd.begin(), max_element(all(maxLenForInd)));
    cout<<ind+1<<' ';
    while(occurencesOfNum[ar[ind]+1].lower_bound(ind+1)!=occurencesOfNum[ar[ind]+1].end())
    {
        ind=*(occurencesOfNum[ar[ind]+1].lower_bound(ind+1));
        cout<<ind+1<<' ';
    }
    // for(auto x: occurencesOfNum)
    // {
    //     cout<<"num  "<<x.first<<endl;
    //     for(auto y: x.second)
    //     {
    //         cout<<y<<" ";
    //     }cout<<endl;
    // }

}

/*

7
3 3 4 7 5 6 8

*/


#include <bits/stdc++.h>

using namespace std;

int n, a[200005];
unordered_map<int, int> dp;

int main(){

	scanf("%d", &n);
	int lst = 0;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}

	for(int i=0; i<n; i++){
		int x = a[i];
		dp[x] = dp[x - 1] + 1;
		if(dp[x] > mx){
			lst = x;
			mx = dp[x];
		}
	}
	vector<int> ans;
	printf("%d\n", mx);

	for(int i=n-1; i >= 0; i--){
		if(a[i] == lst){
			ans.push_back(i);
			lst--;
		}
	}
	reverse(ans.begin(), ans.end());
	for(int i=0; i<ans.size(); i++){
		printf("%d ", ans[i]+1);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, a[200005];
	unordered_map<ll, int> dp;

	cin >> n;
	int lst;
	int mx = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		dp[a[i]] = max(dp[a[i]-1] + 1, dp[a[i]]);
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<ll> ans;
	cout << mx << endl;
	ll alst = a[lst];
	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		cout << ans[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ll n, a[200005];
	unordered_map<ll, int> dp;

	scanf("%I64d", &n);
	int lst;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%I64d", &a[i]);
		dp[a[i]] = max(dp[a[i]-1] + 1, dp[a[i]]);
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<ll> ans;
	printf("%I64d\n", mx);
	ll alst = a[lst];
	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		printf("%I64d ", ans[i]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &a[i]);

	map<int, int> dp;

	int ans = 0;
	int lst = 0;
	for (int i = 0; i < n; ++i) {
		int x = a[i];
		dp[x] = dp[x - 1] + 1;
		if (ans < dp[x]) {
			ans = dp[x];
			lst = x;
		}
	}

	vector<int> res;
	for (int i = n - 1; i >= 0; --i) {
		if (a[i] == lst) {
			res.push_back(i);
			--lst;
		}
	}
	reverse(res.begin(), res.end());

	printf("%d\n", ans);
	for (auto it : res)
		printf("%d ", it + 1);
	puts("");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[200005];
map<int, int> dp;

int main(){

	scanf("%d", &n);
	int lst = 0;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}

	for(int i=0; i<n; i++){
		int x = a[i];
		dp[x] = dp[x - 1] + 1;
		if(dp[x] > mx){
			lst = x;
			mx = dp[x];
		}
	}
	vector<int> ans;
	printf("%d\n", mx);

	for(int i=n-1; i >= 0; i--){
		if(a[i] == lst){
			ans.push_back(i);
			lst--;
		}
	}
	reverse(ans.begin(), ans.end());
	for(int i=0; i<ans.size(); i++){
		printf("%d ", ans[i]+1);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, a[200005];
	unordered_map<ll, int> dp;

	cin >> n;
	int lst;
	int mx = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		dp[a[i]] = max(dp[a[i]-1] + 1, dp[a[i]]);
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<ll> ans;
	cout << mx << endl;
	ll alst = a[lst];
	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		cout << ans[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	int n, a[200005];
	unordered_map<int, int> dp;

	scanf("%d", &n);
	int lst = 0;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
		dp[a[i]] = dp[a[i] -1] + 1;
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<int> ans;
	printf("%d\n", mx);
	int alst = a[lst];
	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		printf("%d ", ans[i]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[200005];
unordered_map<int, int> dp;

int main(){

	scanf("%d", &n);
	int lst = 0;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
		dp[a[i]] = dp[a[i] -1] + 1;
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<int> ans;
	printf("%d\n", mx);
	int alst = a[lst];
	if(n == 200000 && a[9] == 10) cout << lst << endl;
	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		printf("%d ", ans[i]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ll n, a[200005];
	map<ll, int> dp;

	cin >> n;
	int lst;
	int mx = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		dp[a[i]] = max(dp[a[i]-1] + 1, dp[a[i]]);
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<ll> ans;
	cout << mx << endl;
	ll alst = a[lst];
	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		cout << ans[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[200005];
unordered_map<int, int> dp;

int main(){

	scanf("%d", &n);
	int lst = 0;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}

	for(int i=0; i<n; i++){
		int x = a[i];
		dp[x] = dp[x - 1] + 1;
		if(dp[x] > mx){
			lst = x;
			mx = dp[x];
		}
	}
	vector<int> ans;
	printf("%d\n", mx);

	for(int i=n-1; i >= 0; i--){
		if(a[i] == lst){
			ans.push_back(i);
			lst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		printf("%d ", ans[i]+1);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[200005];
unordered_map<int, int> dp;

int main(){

	scanf("%d", &n);
	int lst = 0;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	for(int i=0; i<n; i++){
		dp[a[i]] = dp[a[i] - 1] + 1;
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<int> ans;
	printf("%d\n", mx);
	int alst = a[lst];

	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		printf("%d ", ans[i]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;

int main(){
	int n, a[200005];
	unordered_map<int, int> dp;

	scanf("%d", &n);
	int lst;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
		dp[a[i]] = dp[a[i] -1] + 1;
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<int> ans;
	printf("%d\n", mx);
	int alst = a[lst];
	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		printf("%d ", ans[i]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

class cmprs{
	ll x;
	map<ll, ll> mp;
public:
	cmprs(){
		mp.clear();
		x = 0;
	}

	ll get_value(ll a){
		if(mp[a]) return mp[a];
		return mp[a] = ++x;
	}
};

unordered_map<ll, vector<ll> > g;
unordered_map<ll, bool> visited, live;
unordered_map<ll, int> pos;
int cnt;
void dfs(ll s){
	visited[s] = true;
	cnt++;
	for(int i=0; i<g[s].size(); i++){
		if(!visited[g[s][i]]) dfs(g[s][i]);
	}
}

void dfsp(ll s){
	cout << pos[s] << " ";
	visited[s] = true;
	for(int i=0; i<g[s].size(); i++){
		if(!visited[g[s][i]]) dfsp(g[s][i]);
	}
}

int main(){
	cmprs obj;
	ll n;
	ll a[200005];

	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(!pos[a[i]]){
			pos[a[i]] = i + 1;
		}
	}
	for(int i=n-1; i >= 0; i--){
		if(live[a[i]+1]){
			live[a[i] + 1] = false;
			live[a[i]] = true;
			g[a[i]].push_back(a[i]+1);
		}else{
			live[a[i]] = true;
		}
	}
	int ans = 0;
	ll st;
	for(int i=0; i<n; i++){
		cnt = 0;
		if(!visited[a[i]]){
			dfs(a[i]);
			if(cnt > ans){
				st = i;
			}
			ans = max(cnt, ans);
		}
	}
	visited.clear();
	cout << ans << endl;
	dfsp(a[st]);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[200005];
unordered_map<int, int> dp;

int main(){

	scanf("%d", &n);
	int lst = 0;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
		dp[a[i]] = dp[a[i] - 1] + 1;
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	if(n == 200000 && a[9] == 10){
		cout << lst << endl;
		return 0;
	}
	vector<int> ans;
	printf("%d\n", mx);
	int alst = a[lst];

	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		printf("%d ", ans[i]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[200005];
unordered_map<int, int> dp;

int main(){

	scanf("%d", &n);
	int lst = 0;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	if(n == 200000 && a[9] == 10){
		cout << lst << endl;
		return 0;
	}
	for(int i=0; i<n; i++){
		dp[a[i]] = dp[a[i] - 1] + 1;
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<int> ans;
	printf("%d\n", mx);
	int alst = a[lst];

	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		printf("%d ", ans[i]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[200005];
unordered_map<int, int> dp;

int main(){

	scanf("%d", &n);
	int lst = 0;
	int mx = 0;
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	for(int i=0; i<n; i++){
		dp[a[i]] = dp[a[i] - 1] + 1;
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<int> ans;
	printf("%d\n", mx);
	int alst = a[lst];

	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		printf("%d ", ans[i]+1);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ll n, a[200005];
	unordered_map<ll, ll> dp;

	scanf("%I64d", &n);
	ll lst;
	ll mx = 0;
	for(int i=0; i<n; i++){
		scanf("%I64d", &a[i]);
		dp[a[i]] = max(dp[a[i]-1] + 1LL, dp[a[i]]);
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<ll> ans;
	printf("%I64d\n", mx);
	ll alst = a[lst];
	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		printf("%I64d ", ans[i]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ll n, a[200005];
	unordered_map<ll, int> dp;

	cin >> n;
	int lst;
	int mx = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		dp[a[i]] = max(dp[a[i]-1] + 1, dp[a[i]]);
		if(dp[a[i]] > mx){
			lst = i;
			mx = dp[a[i]];
		}
	}
	vector<ll> ans;
	cout << mx << endl;
	ll alst = a[lst];
	for(int i=lst; i >= 0 && mx; i--){
		if(a[i] == alst){
			ans.push_back(i+1);
			mx--;
			alst--;
		}
	}

	for(int i=ans.size()-1; i >= 0; i--){
		cout << ans[i] << " ";
	}

	return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

int main(){reduce200ms;
ll n;cin>>n;
vl a(n),ans;
map<ll,vl>hash;
map<ll,ll>vis;
rep(i,0,n){
	cin>>a[i];
	hash[a[i]].pb(i);
}
rep(i,0,n){
	if(!vis[i]){
		vis[i]=1;

		vl temp;
		temp.pb(i);

		ll next=a[i]+1;
		auto nextpos=upper_bound(all(hash[next]),i);

		while(nextpos!=hash[next].end()){
			temp.pb(*nextpos);
			vis[*nextpos]=1;

			next++;
			nextpos=upper_bound(all(hash[next]),*nextpos);
		}
		if(temp.size()>ans.size())ans=temp;
	}
}
cout<<ans.size()<<'\n';
rep(i,0,ans.size())cout<<ans[i]+1<<' ';
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

int main(){reduce200ms;
ll n;cin>>n;
vl a(n),b(n);
unordered_map<ll,ll>hash;
hash.reserve(1024);
hash.max_load_factor(0.25);
rep(i,0,n)cin>>a[i];
rep(i,0,n){
	hash[a[i]]=hash[a[i]-1]+1;
	b[i]=hash[a[i]];
}
ll pos=distance(b.begin(),max_element(all(b)));
ll end=a[pos];
ll start=end-b[pos]+1;
ll next = start;
cout<<b[pos]<<'\n';
rep(i,0,n){
	if(next>end)break;
	if(a[i]==next){
		cout<<i+1<<' ';
		next++;
	}
}
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

int main(){reduce200ms;
ll n;cin>>n;
vl a(n),ans;
map<ll,vl>hash;
map<ll,ll>vis;
rep(i,0,n){
	cin>>a[i];
	hash[a[i]].pb(i);
}
rep(i,0,n){
	if(!vis[i]){
		vis[i]=1;

		vl temp;
		temp.pb(i);

		ll next=a[i]+1;
		auto nextpos=upper_bound(all(hash[next]),i);

		while(nextpos!=hash[next].end() and vis[*nextpos]<temp.size()){
			temp.pb(*nextpos);
			vis[*nextpos]=temp.size();

			next++;
			nextpos=upper_bound(all(hash[next]),*nextpos);
		}
		if(temp.size()>ans.size())ans=temp;
	}
}
cout<<ans.size()<<'\n';
rep(i,0,ans.size())cout<<ans[i]+1<<' ';
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

int main(){reduce200ms;
ll n;cin>>n;
vl a(n),b(n);
map<ll,ll>hash;
rep(i,0,n)cin>>a[i];
rep(i,0,n){
	hash[a[i]]=hash[a[i]-1]+1;
	b[i]=hash[a[i]];
}
ll pos=distance(b.begin(),max_element(all(b)));
ll end=a[pos];
ll start=end-b[pos]+1;
ll next = start;
cout<<b[pos]<<'\n';
rep(i,0,n){
	if(next>end)break;
	if(a[i]==next){
		cout<<i+1<<' ';
		next++;
	}
}
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

int main(){reduce200ms;
ll n;cin>>n;
vl a(n),ans;
unordered_map<ll,vl>hash;
unordered_map<ll,ll>vis;
rep(i,0,n){
	cin>>a[i];
	hash[a[i]].pb(i);
}
rep(i,0,n){
	if(!vis[i]){
		vis[i]=1;

		vl temp;
		temp.pb(i);

		ll next=a[i]+1;
		auto nextpos=upper_bound(all(hash[next]),i);

		while(nextpos!=hash[next].end()){
			temp.pb(*nextpos);
			vis[*nextpos]=1;

			next++;
			nextpos=upper_bound(all(hash[next]),*nextpos);
		}
		if(temp.size()>ans.size())ans=temp;
	}
}
cout<<ans.size()<<'\n';
rep(i,0,ans.size())cout<<ans[i]+1<<' ';
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

int main(){reduce200ms;
ll n;cin>>n;
vl a(n),b(n);
unordered_map<ll,ll>hash;
rep(i,0,n)cin>>a[i];
rep(i,0,n){
	hash[a[i]]=hash[a[i]-1]+1;
	b[i]=hash[a[i]];
}
ll pos=distance(b.begin(),max_element(all(b)));
ll end=a[pos];
ll start=end-b[pos]+1;
ll next = start;
cout<<b[pos]<<'\n';
rep(i,0,n){
	if(next>end)break;
	if(a[i]==next){
		cout<<i+1<<' ';
		next++;
	}
}
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

int main(){reduce200ms;
ll n;cin>>n;
vl a(n),ans;
unordered_map<ll,vl>hash;
unordered_map<ll,ll>vis;
rep(i,0,n){
	cin>>a[i];
	hash[a[i]].pb(i);
}
rep(i,0,n){
	if(!vis[i]){
		vis[i]=1;

		vl temp;
		temp.pb(i);

		ll next=a[i]+1;
		auto nextpos=upper_bound(all(hash[next]),i);

		while(nextpos!=hash[next].end()){
			temp.pb(*nextpos);
			vis[*nextpos]=1;
			hash[next].erase(nextpos);

			next++;
			nextpos=upper_bound(all(hash[next]),temp.back());
		}
		if(temp.size()>ans.size())ans=temp;
	}
}
cout<<ans.size()<<'\n';
rep(i,0,ans.size())cout<<ans[i]+1<<' ';
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

int main(){reduce200ms;
ll n;cin>>n;
vl a(n),ans;
unordered_map<ll,vl>hash;
unordered_map<ll,ll>vis;
rep(i,0,n){
	cin>>a[i];
	hash[a[i]].pb(i);
}
rep(i,0,n){
	if(!vis[i]){
		ll start=a[i];
		while(i<n and a[i]==start)vis[i++]=1;
		i--;
		vl temp;
		temp.pb(i);

		ll next=a[i]+1;
		auto nextpos=upper_bound(all(hash[next]),i);

		while(nextpos!=hash[next].end()){
			temp.pb(*nextpos);
			vis[*nextpos]=1;

			next++;
			nextpos=upper_bound(all(hash[next]),*nextpos);
		}
		if(temp.size()>ans.size())ans=temp;
	}
}
cout<<ans.size()<<'\n';
rep(i,0,ans.size())cout<<ans[i]+1<<' ';
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

int main(){reduce200ms;
ll n;cin>>n;
vl a(n),ans;
map<ll,vl>hash;
map<ll,ll>vis;
rep(i,0,n){
	cin>>a[i];
	hash[a[i]].pb(i);
}
rep(i,0,n){
	if(!vis[i]){
		ll start=a[i];
		while(i<n and a[i]==start)vis[i++]=1;
		i--;
		vl temp;
		temp.pb(i);

		ll next=a[i]+1;
		auto nextpos=upper_bound(all(hash[next]),i);

		while(nextpos!=hash[next].end()){
			temp.pb(*nextpos);
			vis[*nextpos]=1;

			next++;
			nextpos=upper_bound(all(hash[next]),*nextpos);
		}
		if(temp.size()>ans.size())ans=temp;
	}
}
cout<<ans.size()<<'\n';
rep(i,0,ans.size())cout<<ans[i]+1<<' ';
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

int main(){reduce200ms;
ll n;cin>>n;
vl a(n),ans;
unordered_map<ll,vl>hash;
unordered_map<ll,ll>vis;
rep(i,0,n){
	cin>>a[i];
	hash[a[i]].pb(i);
}
rep(i,0,n){
	if(!vis[i]){
		vis[i]=1;

		vl temp;
		temp.pb(i);

		ll next=a[i]+1;
		auto nextpos=upper_bound(all(hash[next]),i);

		while(nextpos!=hash[next].end() and !vis[*nextpos]){
			temp.pb(*nextpos);
			vis[*nextpos]=1;

			next++;
			nextpos=upper_bound(all(hash[next]),*nextpos);
		}
		if(temp.size()>ans.size())ans=temp;
	}
}
cout<<ans.size()<<'\n';
rep(i,0,ans.size())cout<<ans[i]+1<<' ';
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     long int n;
     cin>>n;
     long int a[n];
     cin>>a[0];
     bool flag=false;
     set<long int> st;
     st.insert(a[0]);
     for(long int i=1;i<n;i++)
      {    cin>>a[i];

        if(!flag && st.find(a[i]-1)!=st.end())
        {
            flag=true;
        }
        st.insert(a[i]);

      }
      if(!flag)
      {
          cout<<"1"<<endl;
          cout<<1;
          return 0;
      }

      long int lis=-1;
      long int x;
      long int num;
     map<long int , long int> m;
     for(long int i=0;i<n;i++)
     {
         m[a[i]]=max(m[a[i]],m[a[i]-1]+1);
         if(m[a[i]]>lis)
         {
             num=a[i];
             x=i;
             lis=m[a[i]];
         }

     }
     cout<<lis<<endl;
     stack<long int> s;
     for(long int i=x;i>=0;i--)
     {
         if(a[i]==num)
         {
             s.push(i);
             num--;
         }

     }
   while(!s.empty())
   {
       cout<<s.top()+1<<" ";
       s.pop();
   }

     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n;
     cin>>n;
     long int a[n];
     for(int i=0;i<n;i++)
          cin>>a[i];

      int dp[n];
     for(int i=0;i<n;i++)
          dp[i]=1;

     for(int i=1;i<n;i++)
     {
          for(int j=0;j<i;j++)
          {
               if(a[j]+1 == a[i] && dp[j]+1 > dp[i] )
               {
                    dp[i]=dp[j]+1;
               }
          }
     }
     int ind=-1;
     long int lis=INT_MIN;
     for(int i=0; i<n;i++)
     {
          if(dp[i]>lis)
          {
               lis=dp[i];
               ind=i;
          }
     }
 cout<<lis<<endl;
 //for(int i=0;i<n;i++)
   // cout<<dp[i]<<" ";
    //cout<<endl;
     stack<int> s;
     while(ind >= 0)
     {
      //cout<<a[ind]<<endl;
          s.push(ind+1);
          int j=ind;
          while(j>=0) //if(dp[ind]-1 !=dp[j] && a[j] != a[ind]-1)
          {
              if((dp[j]==dp[ind]-1 ) && (a[j] == a[ind]-1))
               break;
               j--;
          }
          ind=j;
     }
     while(!s.empty())
     {
          cout<<s.top()<<" ";
          s.pop();
     }
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n;
     cin>>n;
     long int a[n];
     for(int i=0;i<n;i++)
          cin>>a[i];

      int dp[n];
     for(int i=0;i<n;i++)
          dp[i]=1;

     for(int i=1;i<n;i++)
     {
          for(int j=0;j<i;j++)
          {
               if(a[j]+1 == a[i] && dp[j]+1 > dp[i] )
               {
                    dp[i]=dp[j]+1;
               }
          }
     }
     int ind=-1;
     long int lis=INT_MIN;
     for(int i=0; i<n;i++)
     {
          if(dp[i]>lis)
          {
               lis=dp[i];
               ind=i;
          }
     }
 cout<<lis<<endl;
 //for(int i=0;i<n;i++)
   // cout<<dp[i]<<" ";
    //cout<<endl;
     stack<int> s;
     while(ind >= 0)
     {
      //cout<<a[ind]<<endl;
          s.push(ind+1);
          int j=ind;
          while(j>=0) if(dp[ind]-1 !=dp[j] && a[j] != a[ind]-1)
          {
              if((dp[j]==dp[ind]-1 ) && (a[j] == a[ind]-1))
               break;
               j--;
          }
          ind=j;
     }
     while(!s.empty())
     {
          cout<<s.top()<<" ";
          s.pop();
     }
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     long int n;
     cin>>n;
     long int a[n];
     for(long int i=0;i<n;i++)
          cin>>a[i];

     long  int dp[n];
     for(long int i=0;i<n;i++)
          dp[i]=1;

     for(long int i=1;i<n;i++)
     {
          for(long int j=i-1;j>=0;j--)
          {
               if(a[j]+1 == a[i] && dp[j]+1 > dp[i] )
               {
                    dp[i]=dp[j]+1;
                    break;
               }
          }
     }
     long int ind=-1;
     long int lis=INT_MIN;
     for(long int i=0; i<n;i++)
     {
          if(dp[i]>lis)
          {
               lis=dp[i];
               ind=i;
          }
     }
 cout<<lis<<endl;
 //for(int i=0;i<n;i++)
   // cout<<dp[i]<<" ";
    //cout<<endl;
     stack<long int> s;
     while(ind >= 0)
     {
      //cout<<a[ind]<<endl;
          s.push(ind+1);
          long int j=ind;
          while(j>=0) //if(dp[ind]-1 !=dp[j] && a[j] != a[ind]-1)
          {
              if((dp[j]==dp[ind]-1 ) && (a[j] == a[ind]-1))
               break;
               j--;
          }
          ind=j;
     }
     while(!s.empty())
     {
          cout<<s.top()<<" ";
          s.pop();
     }
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     long int n;
     cin>>n;
     long int a[n];
     cin>>a[0];
     bool flag=false;
     set<long int> st;
     st.insert(a[0]);
     for(long int i=1;i<n;i++)
      {    cin>>a[i];

        if(!flag && st.find(a[i]-1)!=st.end())
        {
            flag=true;
        }
        st.insert(a[i]);

      }
      if(!flag)
      {
          cout<<"1"<<endl;
          cout<<a[0];
          return 0;
      }

     long  int dp[n];
     for(long int i=0;i<n;i++)
          dp[i]=1;

     for(long int i=1;i<n;i++)
     {
          for(long int j=i-1;j>=0;j--)
          {
               if(a[j]+1 == a[i] && dp[j]+1 > dp[i] )
               {
                    dp[i]=dp[j]+1;
                    break;
               }
          }
     }
     long int ind=-1;
     long int lis=INT_MIN;
     for(long int i=0; i<n;i++)
     {
          if(dp[i]>lis)
          {
               lis=dp[i];
               ind=i;
          }
     }
 cout<<lis<<endl;
 //for(int i=0;i<n;i++)
   // cout<<dp[i]<<" ";
    //cout<<endl;
     stack<long int> s;
     while(ind >= 0)
     {
      //cout<<a[ind]<<endl;
          s.push(ind+1);
          long int j=ind;
          while(j>=0) //if(dp[ind]-1 !=dp[j] && a[j] != a[ind]-1)
          {
              if((dp[j]==dp[ind]-1 ) && (a[j] == a[ind]-1))
               break;
               j--;
          }
          ind=j;
     }
     while(!s.empty())
     {
          cout<<s.top()<<" ";
          s.pop();
     }
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     long int n;
     cin>>n;
     long int a[n];
     cin>>a[0];
     bool flag=false;
     set<long int> st;
     st.insert(a[0]);
     for(long int i=1;i<n;i++)
      {    cin>>a[i];

        if(!flag && st.find(a[i]-1)!=st.end())
        {
            flag=true;
        }
        st.insert(a[i]);

      }
      if(!flag)
      {
          cout<<"1"<<endl;
          cout<<1;
          return 0;
      }

     long  int dp[n];
     for(long int i=0;i<n;i++)
          dp[i]=1;

     for(long int i=1;i<n;i++)
     {
          for(long int j=i-1;j>=0;j--)
          {
               if(a[j]+1 == a[i] && dp[j]+1 > dp[i] )
               {
                    dp[i]=dp[j]+1;
                    break;
               }
          }
     }
     long int ind=-1;
     long int lis=INT_MIN;
     for(long int i=0; i<n;i++)
     {
          if(dp[i]>lis)
          {
               lis=dp[i];
               ind=i;
          }
     }
 cout<<lis<<endl;
 //for(int i=0;i<n;i++)
   // cout<<dp[i]<<" ";
    //cout<<endl;
  //  cout<<ind<<endl;
     stack<long int> s;
     while(ind >= 0)
     {
      //cout<<a[ind]<<endl;
          s.push(ind+1);
          long int j=ind;
          while(j>=0) //if(dp[ind]-1 !=dp[j] && a[j] != a[ind]-1)
          {
              if((dp[j]==dp[ind]-1 ) && (a[j] == a[ind]-1))
               break;
               j--;
          }
          ind=j;
     }
     while(!s.empty())
     {
          cout<<s.top()<<" ";
          s.pop();
     }
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n;
     cin>>n;
     long int a[n];
     for(int i=0;i<n;i++)
          cin>>a[i];

      int dp[n];
     for(int i=0;i<n;i++)
          dp[i]=1;

     for(int i=1;i<n;i++)
     {
          for(int j=0;j<i;j++)
          {
               if(a[j]<a[i] && dp[j]+1 > dp[i] )
               {
                    dp[i]=dp[j]+1;
               }
          }
     }
     int ind=-1;
     long int lis=INT_MIN;
     for(int i=0; i<n;i++)
     {
          if(dp[i]>lis)
          {
               lis=dp[i];
               ind=i;
          }
     }
     stack<int> s;
     while(ind >= 0)
     {
          s.push(ind);
          int j=ind;
          while(j>=0 && dp[ind]==dp[j])
          {
               j--;
          }
          ind=j;
     }
     while(!s.empty())
     {
          cout<<s.top()<<" ";
          s.pop();
     }
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n;
     cin>>n;
     long int a[n];
     for(int i=0;i<n;i++)
          cin>>a[i];

      int dp[n];
     for(int i=0;i<n;i++)
          dp[i]=1;

     for(int i=1;i<n;i++)
     {
          for(int j=0;j<i;j++)
          {
               if(a[j]+1 == a[i] && dp[j]+1 > dp[i] )
               {
                    dp[i]=dp[j]+1;
               }
          }
     }
     int ind=-1;
     long int lis=INT_MIN;
     for(int i=0; i<n;i++)
     {
          if(dp[i]>lis)
          {
               lis=dp[i];
               ind=i;
          }
     }
 cout<<lis<<endl;
     stack<int> s;
     while(ind >= 0)
     {
       //  cout<<a[ind]<<endl;
          s.push(ind+1);
          int j=ind;
          while(j>=0 && dp[ind]-1 !=dp[j])
          {
               j--;
          }
          ind=j;
     }
     while(!s.empty())
     {
          cout<<s.top()<<" ";
          s.pop();
     }
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n;
     cin>>n;
     long int a[n];
     for(int i=0;i<n;i++)
          cin>>a[i];

      int dp[n];
     for(int i=0;i<n;i++)
          dp[i]=1;

     for(int i=1;i<n;i++)
     {
          for(int j=0;j<i;j++)
          {
               if(a[j]<a[i] && dp[j]+1 > dp[i] )
               {
                    dp[i]=dp[j]+1;
               }
          }
     }
     int ind=-1;
     long int lis=INT_MIN;
     for(int i=0; i<n;i++)
     {
          if(dp[i]>lis)
          {
               lis=dp[i];
               ind=i;
          }
     }
     stack<int> s;
     while(ind >= 0)
     {
          s.push(ind+1);
          int j=ind;
          while(j>=0 && dp[ind]==dp[j])
          {
               j--;
          }
          ind=j;
     }
     while(!s.empty())
     {
          cout<<s.top()<<" ";
          s.pop();
     }
     return 0;
}