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

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

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

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

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

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

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

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

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

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

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

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

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

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

  ll temp[110][110];

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

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

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

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

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

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

    n/=2;
  }

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

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

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

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

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

ll lpf[1000001] = {};

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

ll fact[2000010];

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

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

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

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

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

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

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

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

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

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

  return -1;
}

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

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

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

int main()
{
  fast;

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

  ll temp[110][110];

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

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

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

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

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

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

    n/=2;
  }

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

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

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

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

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

ll lpf[1000001] = {};

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

ll fact[2000010];

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

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

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

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

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

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

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

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

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

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

  return -1;
}

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

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

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

int main()
{
  fast;

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

  ll temp[110][110];

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

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

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

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

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

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

    n/=2;
  }

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

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

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

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

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

ll lpf[1000001] = {};

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

ll fact[2000010];

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

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

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

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

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

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

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

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

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

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

  return -1;
}

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

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

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

int main()
{
  fast;

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

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

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

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

  rep(o,n)
  {
    if(mx[arr[o]]==maxo)
    {
      cout<<maxo<<endl;
      vector<ll> jk=vx[arr[o]];
      rep(p,jk.size())
      {
        cout<<jk[p]<<" ";
      }
      cout<<endl;
      break;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    unordered_map< int , int > data;

    pair<int,int> * dp = new pair<int,int >[n];
    for(int i=0;i<n ; i++)
    {
        if( data.count(a[i]-1)== 0  )
        {
            dp[i] = make_pair(1 , i );
        }
        else
        {
            int j = data[ a[i] -1 ]  ;
            if( dp[j].first+1 > dp[i].first )
            {

                dp[i] = make_pair( dp[j].first+1 , j );
                data[ a[i] ] = i;
            }

        }
        if( dp[data[ a[i] ] ] .first < dp[i].first )
            data[ a[i] ] = i ;
    }

    int msize = 0 ;
    int index =0;
    for(int i=0;i<n;i++)
    {
        if( msize < dp[i].first )
        {
            msize = dp[i].first;
            index   = i;
        }
    }
    cout<<msize<<endl;
    int i = index;
    vector<int> ans;
    while( i != dp[i].second)
    {
        ans.push_back( i );
        i = dp[i].second;
    }

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


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n ;
    cin>>n;
    int a[n];
    map<int , int > data;
    int ans =0;
    int val  = 0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        data[ a[i]  ] = 1+ data[ a[i]-1 ];
        if( ans< data[ a[i] ] )
        {
            ans = data[ a[i] ];
            val = a[i];
        }
    }

    val = val - ans +1;
    int t = val;
    cout<<ans<<endl;
    for( int i=0 ; i< n ;i++)
    {
        if( a[i] == t  )
        {
            cout<<i+1<<" ";
            t++;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }

    set<ll> * dp = new set<ll>[n];
    for(int i=0;i<n ; i++)
    {
        dp[i].insert( i+1 );
        for( int j = i-1;j>=0 ; j--)
        {
            if( a[j] ==a[i]-1 )
            {
                if( dp[j].size() +1 > dp[i].size()  )
                {
                    dp[i] = dp[j];
                    dp[i].insert( i +1  );
                }
            }
        }
    }

    int msize = 0 ;
    int index =0;
    for(int i=0;i<n;i++)
    {
        if( msize < dp[i].size() )
        {
            msize = dp[i].size();
            index   = i;
        }
    }
    cout<<dp[index].size()<<endl;
    for( auto it : dp[index ])
    {
        cout<<it<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n ;
    cin>>n;
    int a[n];
    unordered_map<int , int > data;
    int ans =0;
    int val  = 0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        data[ a[i]  ] = 1+ data[ a[i]-1 ];
        if( ans< data[ a[i] ] )
        {
            ans = data[ a[i] ];
            val = a[i];
        }
    }

    val = val - ans +1;
    int t = val;
    cout<<ans<<endl;
    for( int i=0 ; i< n ;i++)
    {
        if( a[i] == t  )
        {
            cout<<i+1<<" ";
            t++;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0; i < n; i++)
    {
        cin>>a[i];
    }
    unordered_map<ll, ll> data;

    pair<ll, ll> * dp = new pair<ll, ll>[n];
    for(ll i=0; i < n ; i++)
    {
        if( data.count(a[i]-1)== 0  )
        {
            dp[i] = make_pair(1 , i );
        }
        else
        {
            ll j = data[a[i] - 1 ]  ;
            if( dp[j].first+1 > dp[i].first )
            {

                dp[i] = make_pair( dp[j].first+1 , j );
                data[ a[i] ] = i;
            }

        }
        if( dp[data[ a[i] ] ] .first < dp[i].first )
            data[ a[i] ] = i ;
    }

    ll msize = 0 ;
    ll index =0;
    for(ll i=0; i < n; i++)
    {
        if( msize < dp[i].first )
        {
            msize = dp[i].first;
            index   = i;
        }
    }
    cout<<msize<<endl;
    ll i = index;
    vector<ll> ans;
    while( i != dp[i].second)
    {
        ans.push_back( i );
        i = dp[i].second;
    }
    ans.push_back( i );
    for(ll i= ans.size() - 1; i >= 0 ; i--)
    {
        cout<< ans[i]+1<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    unordered_map< int , int > data;

    set<int> * dp = new set<int>[n];
    for(int i=0;i<n ; i++)
    {
        if( data.count(a[i]-1)== 0  )
        {
            dp[i].insert( i+1 );
        }
        else
        {
            int j = data[ a[i] -1 ]  ;
            if( dp[j].size()+1 > dp[i].size() )
            {
                dp[i] = dp[j];
                dp[i].insert(i+1);
                data[ a[i] ] = i;
            }

        }
        if( dp[data[ a[i] ] ] .size() < dp[i].size() )
            data[ a[i] ] = i ;
    }

    int msize = 0 ;
    int index =0;
    for(int i=0;i<n;i++)
    {
        if( msize < dp[i].size() )
        {
            msize = dp[i].size();
            index   = i;
        }
    }
    cout<<dp[index].size()<<endl;
    for( auto it : dp[index ])
    {
        cout<<it<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    unordered_map< int , int > data;

    pair<int,int> * dp = new pair<int,int >[n];
    for(int i=0;i<n ; i++)
    {
        if( data.count(a[i]-1)== 0  )
        {
            dp[i] = make_pair(1 , i );
        }
        else
        {
            int j = data[ a[i] -1 ]  ;
            if( dp[j].first+1 > dp[i].first )
            {

                dp[i] = make_pair( dp[j].first+1 , j );
                data[ a[i] ] = i;
            }

        }
        if( dp[data[ a[i] ] ] .first < dp[i].first )
            data[ a[i] ] = i ;
    }

    int msize = 0 ;
    int index =0;
    for(int i=0;i<n;i++)
    {
        if( msize < dp[i].first )
        {
            msize = dp[i].first;
            index   = i;
        }
    }
    cout<<msize<<endl;
    int i = index;
    vector<int> ans;
    while( i != dp[i].second)
    {
        ans.push_back( i );
        i = dp[i].second;
    }
    ans.push_back( i );
    for(int i= ans.size()-1;i>=0 ;i--)
    {
        cout<< ans[i]+1<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n ;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    unordered_map<int , int > data;
    int ans =0;
    int val  = 0;
    for(int i=0;i<n;i++)
    {
        data[ a[i]  ] = 1+ data[ a[i]-1 ];
        if( ans< data[ a[i] ] )
        {
            ans = data[ a[i] ];
            val = a[i];
        }
    }
    val = val - ans +1;
    int t = val;
    cout<<ans<<endl;
    for( int i=0 ; i< n ;i++)
    {
        if( a[i] == t  )
        {
            cout<<i+1<<" ";
            t++;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    unordered_map< int , int > data;

    set<ll> * dp = new set<ll>[n];
    for(int i=0;i<n ; i++)
    {
        if( data.count(a[i]-1)== 0  )
        {
            dp[i].insert( i+1 );
        }
        else
        {
            int j = data[ a[i] -1 ]  ;
            if( dp[j].size()+1 > dp[i].size() )
            {
                dp[i] = dp[j];
                dp[i].insert(i+1);
                data[ a[i] ] = i;
            }

        }

        if( dp[data[ a[i] ] ] .size() < dp[i].size() )
            data[ a[i] ] = i ;
    }

    int msize = 0 ;
    int index =0;
    for(int i=0;i<n;i++)
    {
        if( msize < dp[i].size() )
        {
            msize = dp[i].size();
            index   = i;
        }
    }
    cout<<dp[index].size()<<endl;
    for( auto it : dp[index ])
    {
        cout<<it<<" ";
    }
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  vector<int> v(n);
  for (int& e : v) cin >> e;

  unordered_map<int, int> dp;
  unordered_map<int, int> pos;
  vector<int> successor(n, -1);
  for (int i = n - 1; i >= 0; i--) {
    int m = v[i];
    int next = m + 1;
    dp[m] = 1;
    if (dp[next] >= dp[m]) {
      dp[m] = dp[next] + 1;
      successor[i] = pos[next];
    }
    pos[m] = i;
  }

  int best = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    int m = v[i];
    if (dp[m] > best) {
      best = dp[m];
      index = i;
    }
  }

  cout << best << endl;
  while (index != -1) {
    cout << index + 1 << " ";
    index = successor[index];
  }
  cout << endl;

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  vector<int> v(n);
  for (int& e : v) scanf("%d", &e);

  unordered_map<int, int> dp;
  unordered_map<int, int> pos;
  vector<int> successor(n, -1);
  for (int i = n - 1; i >= 0; i--) {
    int m = v[i];
    int next = m + 1;
    dp[m] = 1;
    if (dp[next] >= dp[m]) {
      dp[m] = dp[next] + 1;
      successor[i] = pos[next];
    }
    pos[m] = i;
  }

  int best = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    int m = v[i];
    if (dp[m] > best) {
      best = dp[m];
      index = i;
    }
  }

  cout << best << endl;
  while (index != -1) {
    cout << index + 1 << " ";
    index = successor[index];
  }
  cout << endl;

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);

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

  int best[n];
  int successor[n];
  map<int, int> pos;
  int len = 0;
  int index = 0;
  for (int i = n - 1; i >= 0; i--) {
    successor[i] = -1;
    best[i] = 1;

    int m = v[i];
    int next = m + 1;
    if (pos.find(next) != pos.end()) {
      successor[i] = pos[next];
      best[i] = best[successor[i]] + 1;
    }
    pos[m] = i;

    if (best[i] > len) {
      len = best[i];
      index = i;
    }
  }

  printf("%d\n", len);
  while (len > 0) {
    printf("%d ", index + 1);
    index = successor[index];
    len--;
  }
  printf("\n");

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  int v[n];
  for (int& e : v) scanf("%d", &e);

  int best[n];
  int successor[n];
  unordered_map<int, int> pos;
  for (int i = n - 1; i >= 0; i--) {
    successor[i] = -1;
    best[i] = 1;

    int m = v[i];
    int next = m + 1;
    if (pos.find(next) != pos.end()) {
      successor[i] = pos[next];
      best[i] = best[successor[i]] + 1;
    }
    pos[m] = i;
  }

  int len = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    if (best[i] > len) {
      len = best[i];
      index = i;
    }
  }

  cout << len << endl;
  while (index != -1 && len > 0) {
    printf("%d ", index + 1);
    index = successor[index];
    len--;
  }
  cout << endl;

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  vector<int> v(n);
  for (int& e : v) cin >> e;

  unordered_map<int, int> dp;
  unordered_map<int, int> pos;
  vector<int> successor(n, -1);
  for (int i = n - 1; i >= 0; i--) {
    int m = v[i];
    int next = m + 1;
    dp[m] = 1;
    if (dp[next] >= dp[m]) {
      dp[m] = dp[next] + 1;
      successor[i] = pos[next];
    }
    if (pos.find(m) == pos.end()) {
      pos[m] = i;
    }
  }

  int best = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    int m = v[i];
    if (dp[m] > best) {
      best = dp[m];
      index = i;
    }
  }

  cout << best << endl;
  while (index != -1) {
    cout << index + 1 << " ";
    index = successor[index];
  }
  cout << endl;

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);

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

  int best[n];
  int successor[n];
  unordered_map<int, int> pos(n);
  int len = 0;
  int index = 0;
  for (int i = n - 1; i >= 0; i--) {
    successor[i] = -1;
    best[i] = 1;

    int m = v[i];
    int next = m + 1;
    if (pos.find(next) != pos.end()) {
      successor[i] = pos[next];
      best[i] = best[successor[i]] + 1;
    }
    pos[m] = i;

    if (best[i] > len) {
      len = best[i];
      index = i;
    }
  }

  printf("%d\n", len);
  while (len > 0) {
    printf("%d ", index + 1);
    index = successor[index];
    len--;
  }
  printf("\n");

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  vector<int> v(n);
  for (int& e : v) scanf("%d", &e);

  unordered_map<int, int> dp;
  unordered_map<int, int> pos;
  vector<int> successor(n, -1);
  for (int i = n - 1; i >= 0; i--) {
    int m = v[i];
    int next = m + 1;
    dp[m] = max(dp[m], 1);
    if (dp[next] >= dp[m]) {
      dp[m] = dp[next] + 1;
      successor[i] = pos[next];
    }
    pos[m] = i;
  }

  int best = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    int m = v[i];
    if (dp[m] > best) {
      best = dp[m];
      index = i;
    }
  }

  cout << best << endl;
  while (index != -1) {
    cout << index + 1 << " ";
    index = successor[index];
  }
  cout << endl;

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  vector<int> v(n);
  for (int& e : v) scanf("%d", &e);

  vector<int> best(n, 1);
  vector<int> successor(n, -1);
  unordered_map<int, int> pos;
  for (int i = n - 1; i >= 0; i--) {
    int m = v[i];
    int next = m + 1;
    if (pos.find(next) != pos.end()) {
      successor[i] = pos[next];
      best[i] = best[successor[i]] + 1;
    }
    pos[m] = i;
  }

  int len = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    if (best[i] > len) {
      len = best[i];
      index = i;
    }
  }

  cout << len << endl;
  while (index != -1) {
    printf("%d ", index + 1);
    index = successor[index];
  }
  cout << endl;

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);

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

  int best[n];
  int successor[n];
  unordered_map<int, int> pos;
  int len = 0;
  int index = 0;
  for (int i = n - 1; i >= 0; i--) {
    successor[i] = -1;
    best[i] = 1;

    int m = v[i];
    int next = m + 1;
    if (pos.find(next) != pos.end()) {
      successor[i] = pos[next];
      best[i] = best[successor[i]] + 1;
    }
    pos[m] = i;

    if (best[i] > len) {
      len = best[i];
      index = i;
    }
  }

  printf("%d\n", len);
  while (len > 0) {
    printf("%d ", index + 1);
    index = successor[index];
    len--;
  }
  printf("\n");

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  vector<int> v(n);
  for (int& e : v) scanf("%d", &e);

  vector<int> best(n, 1);
  vector<int> successor(n, -1);
  unordered_map<int, int> pos;
  for (int i = n - 1; i >= 0; i--) {
    int m = v[i];
    int next = m + 1;
    if (pos.find(next) != pos.end()) {
      successor[i] = pos[next];
      best[i] = best[successor[i]] + 1;
    }
    pos[m] = i;
  }

  int len = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    if (best[i] > len) {
      len = best[i];
      index = i;
    }
  }

  cout << len << endl;
  while (index != -1) {
    cout << index + 1 << " ";
    index = successor[index];
  }
  cout << endl;

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  int v[n];
  for (int& e : v) scanf("%d", &e);

  int best[n];
  int successor[n];
  unordered_map<int, int> pos;
  for (int i = n - 1; i >= 0; i--) {
    successor[i] = -1;
    best[i] = 1;

    int m = v[i];
    int next = m + 1;
    if (pos.find(next) != pos.end()) {
      successor[i] = pos[next];
      best[i] = best[successor[i]] + 1;
    }
    pos[m] = i;
  }

  int len = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    if (best[i] > len) {
      len = best[i];
      index = i;
    }
  }

  cout << len << endl;
  while (index < n && index >= 0 && len > 0) {
    printf("%d ", index + 1);
    index = successor[index];
    len--;
  }
  cout << endl;

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  vector<int> v(n);
  for (int& e : v) scanf("%d", &e);

  vector<int> best(n, 1);
  vector<int> successor(n, -1);
  unordered_map<int, int> pos;
  for (int i = n - 1; i >= 0; i--) {
    int m = v[i];
    int next = m + 1;
    if (pos.find(next) != pos.end()) {
      successor[i] = pos[next];
      best[i] = best[successor[i]] + 1;
    }
    pos[m] = i;
  }

  int len = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    if (best[i] > len) {
      len = best[i];
      index = i;
    }
  }

  cout << len << endl;
  while (index != -1 && len > 0) {
    printf("%d ", index + 1);
    index = successor[index];
    len--;
  }
  cout << endl;

  return 0;
}


#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define ulli  unsigned ll int
#define sl(n) scanf("%lld", &n)
#define sl2(a,b) scanf("%lld%lld", &a,&b)
#define sl3(a,b,c) scanf("%lld%lld%lld", &a,&b,&c)
#define VI  vector<int>
#define Vll  vector<ll>
#define   all(v)  v.begin(),v.end()
#define ub(v,x)  upper_bound(all(v),x)

bool check(int x,int pos){return  (bool)(x &(1<<pos));}
int st(int x,int pos){  return x= x |(1<<pos);}
int  Reset(int x,int pos ){ return x= x &~(1<<pos);}

#define si(n) scanf("%d", &n)
#define si2(a,b) scanf("%d%d", &a,&b)
#define si3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define sf(n) scanf("%lf", &n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define mkpr  make_pair
#define   ff   first
#define   ss  second
#define  srt(V)  sort(V.begin(),V.end());
#define nl printf("\n");
#define  PI  2*acos(0.0);
#define  INFP ((ll)1<<62)
#define  INFN (0-(ll)1<<62)
#define  loop(a,b)  for(int g=a;g<=b;g++)
#define  for1(n)  for(int i=0;i<n;i++)
#define  for2(n)  for(int j=0;j<n;j++)
#define  for3(n)  for(int k=0;k<n;k++)
#define  for4(n)  for(int l=0;l<n;l++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define  bug1(a)  cout<<a<<endl;
#define  bug2(a,b)  cout<<a<<" "<<b<<endl;
#define  bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
#define  bug4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define  tst(n)  for(int cs=1;cs<=n;cs++)
#define spc <<" "<<
#define  pys puts("YES");
#define  pno  puts("NO");
#define bug puts("bug");
#define  pmn puts("-1");
#define zero puts("0");
#define limit 200006
#define md 1000000007

typedef pair<ll,ll> iPair;

map<ll,set<ll> >mp;

ll A[limit];
bool visited[limit];

int main()
{
      memset(visited,0,sizeof visited);

       /*freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);*/

       ll n;

       cin>>n;

       for(int i=1;i<=n;i++)
       {

        sl(A[i]);
        mp[A[i]].insert(i);

       }

       ll mx=0,st,s,z,c;

       for(int i=1;i<=n;i++)
       {
           s=A[i];
           z=i,c=1;

          if(visited[z])continue;
          visited[z]=true;
        while(mp[s+1].upper_bound(z)!=mp[s+1].end())
        {

          auto it=mp[s+1].upper_bound(z);

          if(*it<z)
          {

              break;
          }

          z=*it;
          visited[z]=true;

          s=A[z];

        c++;
        }

        //mx=max(mx,c);
        if(mx<c)
        {

          mx=c;
          st=i;
        }

       }

       cout<<mx<<endl;

        s=A[st];
       z=st;
       cout<<st<<" ";

       while(mp[s+1].upper_bound(z)!=mp[s+1].end())
        {

          auto it=mp[s+1].upper_bound(z);

          if(*it<z)
          {

              break;
          }

          z=*it;

          cout<<z<<" ";
          visited[z]=true;

          s=A[z];

        c++;
        }
        nl

        /**
       *    @author     : Ikbal Hossain
       *    @University  : RUET CSE 15
       *    @CodeForces : iAmrifat
       *    @UVA        : rifat_ikbal
       *    @facebook   : https://www.facebook.com/ikbal.rifat.5
       */

      /* ll dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
      /* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
      /* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
      /* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction

}


#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define ulli  unsigned ll int
#define sl(n) scanf("%lld", &n)
#define sl2(a,b) scanf("%lld%lld", &a,&b)
#define sl3(a,b,c) scanf("%lld%lld%lld", &a,&b,&c)
#define VI  vector<int>
#define Vll  vector<ll>
#define   all(v)  v.begin(),v.end()
#define ub(v,x)  upper_bound(all(v),x)

bool check(int x,int pos){return  (bool)(x &(1<<pos));}
int st(int x,int pos){  return x= x |(1<<pos);}
int  Reset(int x,int pos ){ return x= x &~(1<<pos);}

#define si(n) scanf("%d", &n)
#define si2(a,b) scanf("%d%d", &a,&b)
#define si3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define sf(n) scanf("%lf", &n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define mkpr  make_pair
#define   ff   first
#define   ss  second
#define  srt(V)  sort(V.begin(),V.end());
#define nl printf("\n");
#define  PI  2*acos(0.0);
#define  INFP ((ll)1<<62)
#define  INFN (0-(ll)1<<62)
#define  loop(a,b)  for(int g=a;g<=b;g++)
#define  for1(n)  for(int i=0;i<n;i++)
#define  for2(n)  for(int j=0;j<n;j++)
#define  for3(n)  for(int k=0;k<n;k++)
#define  for4(n)  for(int l=0;l<n;l++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define  bug1(a)  cout<<a<<endl;
#define  bug2(a,b)  cout<<a<<" "<<b<<endl;
#define  bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
#define  bug4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define  tst(n)  for(int cs=1;cs<=n;cs++)
#define spc <<" "<<
#define  pys puts("YES");
#define  pno  puts("NO");
#define bug puts("bug");
#define  pmn puts("-1");
#define zero puts("0");
#define limit 200006
#define md 1000000007

typedef pair<ll,ll> iPair;

map<ll,set<ll> >mp;

ll A[limit];
bool visited[limit];

int main()
{
      memset(visited,0,sizeof visited);

     /*  freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);*/

       ll n;

       cin>>n;
       set<iPair>mp;

       for(int i=1;i<=n;i++)
       {

        sl(A[i]);
        mp.insert({A[i],i});

        //mp[A[i]].insert(i);

       }

       ll mx=0,st,s,z,c;

       for(int i=1;i<=n;i++)
       {
           s=A[i];
           z=i,c=1;

          if(visited[z])continue;
          visited[z]=true;
        while(mp.upper_bound({s+1,z})!=mp.end())
        {

          auto it=mp.upper_bound({s+1,z});

          if(it->ss<z||it->ff!=(s+1))
          {

              break;
          }

          z=it->ss;
          visited[z]=true;

          s=A[z];

        c++;
        }

        //mx=max(mx,c);
        if(mx<c)
        {

          mx=c;
          st=i;
        }

       }

       cout<<mx<<endl;

        s=A[st];
       z=st;
       cout<<st<<" ";

       while(mp.upper_bound({s+1,z})!=mp.end())
        {

          auto it=mp.upper_bound({s+1,z});

          if(it->ss<z||it->ff!=(s+1))
          {

              break;
          }

          z=it->ss;

            cout<<z<<" ";
          s=A[z];

        }
        nl

        /**
       *    @author     : Ikbal Hossain
       *    @University  : RUET CSE 15
       *    @CodeForces : iAmrifat
       *    @UVA        : rifat_ikbal
       *    @facebook   : https://www.facebook.com/ikbal.rifat.5
       */

      /* ll dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
      /* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
      /* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
      /* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction

}


#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define ulli  unsigned ll int
#define sl(n) scanf("%lld", &n)
#define sl2(a,b) scanf("%lld%lld", &a,&b)
#define sl3(a,b,c) scanf("%lld%lld%lld", &a,&b,&c)
#define VI  vector<int>
#define Vll  vector<ll>
#define   all(v)  v.begin(),v.end()
#define ub(v,x)  upper_bound(all(v),x)

bool check(int x,int pos){return  (bool)(x &(1<<pos));}
int st(int x,int pos){  return x= x |(1<<pos);}
int  Reset(int x,int pos ){ return x= x &~(1<<pos);}

#define si(n) scanf("%d", &n)
#define si2(a,b) scanf("%d%d", &a,&b)
#define si3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define sf(n) scanf("%lf", &n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define mkpr  make_pair
#define   ff   first
#define   ss  second
#define  srt(V)  sort(V.begin(),V.end());
#define nl printf("\n");
#define  PI  2*acos(0.0);
#define  INFP ((ll)1<<62)
#define  INFN (0-(ll)1<<62)
#define  loop(a,b)  for(int g=a;g<=b;g++)
#define  for1(n)  for(int i=0;i<n;i++)
#define  for2(n)  for(int j=0;j<n;j++)
#define  for3(n)  for(int k=0;k<n;k++)
#define  for4(n)  for(int l=0;l<n;l++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define  bug1(a)  cout<<a<<endl;
#define  bug2(a,b)  cout<<a<<" "<<b<<endl;
#define  bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
#define  bug4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define  tst(n)  for(int cs=1;cs<=n;cs++)
#define spc <<" "<<
#define  pys puts("YES");
#define  pno  puts("NO");
#define bug puts("bug");
#define  pmn puts("-1");
#define zero puts("0");
#define limit 200006
#define md 1000000007

typedef pair<ll,ll> iPair;

//map<ll,set<ll> >mp;

ll A[limit];
bool visited[limit];

int main()
{
      memset(visited,0,sizeof visited);

     /*  freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);*/

       ll n;

       cin>>n;
       set<iPair>mp;

       for(int i=1;i<=n;i++)
       {

        sl(A[i]);
        mp.insert({A[i],i});

        //mp[A[i]].insert(i);

       }

       ll mx=0,st,s,z,c;

       for(ll i=1;i<=n;i++)
       {
           s=A[i];
           z=i,c=1;

          if(visited[z])continue;

          visited[z]=true;
          auto it=mp.upper_bound({s+1,z});
        while(it!=mp.end())
        {

          if(it->ss<z||it->ff!=(s+1))
          {

              break;
          }

          z=it->ss;
          visited[z]=true;

          s=A[z];

        c++;

        it=mp.upper_bound({s+1,z});
        }

        //mx=max(mx,c);
        if(mx<c)
        {

          mx=c;
          st=i;
        }

       }

       cout<<mx<<endl;

        s=A[st];
       z=st;
        printf("%lld ",z);
          auto it=mp.upper_bound({s+1,z});

       while(it!=mp.end())
        {

          if(it->ss<z||it->ff!=(s+1))
          {

              break;
          }

          z=it->ss;

          printf("%lld ",z);
          s=A[z];

         it=mp.upper_bound({s+1,z});

        }
        nl

        /**
       *    @author     : Ikbal Hossain
       *    @University  : RUET CSE 15
       *    @CodeForces : iAmrifat
       *    @UVA        : rifat_ikbal
       *    @facebook   : https://www.facebook.com/ikbal.rifat.5
       */

      /* ll dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
      /* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
      /* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
      /* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction

}


#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define ulli  unsigned ll int
#define sl(n) scanf("%lld", &n)
#define sl2(a,b) scanf("%lld%lld", &a,&b)
#define sl3(a,b,c) scanf("%lld%lld%lld", &a,&b,&c)
#define VI  vector<int>
#define Vll  vector<ll>
#define   all(v)  v.begin(),v.end()
#define ub(v,x)  upper_bound(all(v),x)

bool check(int x,int pos){return  (bool)(x &(1<<pos));}
int st(int x,int pos){  return x= x |(1<<pos);}
int  Reset(int x,int pos ){ return x= x &~(1<<pos);}

#define si(n) scanf("%d", &n)
#define si2(a,b) scanf("%d%d", &a,&b)
#define si3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define sf(n) scanf("%lf", &n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define mkpr  make_pair
#define   ff   first
#define   ss  second
#define  srt(V)  sort(V.begin(),V.end());
#define nl printf("\n");
#define  PI  2*acos(0.0);
#define  INFP ((ll)1<<62)
#define  INFN (0-(ll)1<<62)
#define  loop(a,b)  for(int g=a;g<=b;g++)
#define  for1(n)  for(int i=0;i<n;i++)
#define  for2(n)  for(int j=0;j<n;j++)
#define  for3(n)  for(int k=0;k<n;k++)
#define  for4(n)  for(int l=0;l<n;l++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define  bug1(a)  cout<<a<<endl;
#define  bug2(a,b)  cout<<a<<" "<<b<<endl;
#define  bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
#define  bug4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define  tst(n)  for(int cs=1;cs<=n;cs++)
#define spc <<" "<<
#define  pys puts("YES");
#define  pno  puts("NO");
#define bug puts("bug");
#define  pmn puts("-1");
#define zero puts("0");
#define limit 200006
#define md 1000000007

typedef pair<ll,ll> iPair;

//map<ll,set<ll> >mp;

ll A[limit];
bool visited[limit];

int main()
{
      memset(visited,0,sizeof visited);
        /*
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);*/

       ll n;

       cin>>n;
       set<iPair>mp;

       for(int i=1;i<=n;i++)
       {

        sl(A[i]);
        mp.insert({A[i],i});

        //mp[A[i]].insert(i);

       }

       ll mx=0,st,s,z,c;

       for(int i=1;i<=n;i++)
       {
           s=A[i];
           z=i,c=1;

          if(visited[z])continue;
          visited[z]=true;
          auto it=mp.upper_bound({s+1,z});
        while(it!=mp.end())
        {

          if(it->ss<z||it->ff!=(s+1))
          {

              break;
          }

          z=it->ss;
          visited[z]=true;

          s=A[z];

        c++;

        it=mp.upper_bound({s+1,z});
        }

        //mx=max(mx,c);
        if(mx<c)
        {

          mx=c;
          st=i;
        }

       }

       cout<<mx<<endl;

        s=A[st];
       z=st;
        printf("%lld ",z);

       while(mp.upper_bound({s+1,z})!=mp.end())
        {

          auto it=mp.upper_bound({s+1,z});

          if(it->ss<z||it->ff!=(s+1))
          {

              break;
          }

          z=it->ss;

          printf("%lld ",z);
          s=A[z];

        }
        nl

        /**
       *    @author     : Ikbal Hossain
       *    @University  : RUET CSE 15
       *    @CodeForces : iAmrifat
       *    @UVA        : rifat_ikbal
       *    @facebook   : https://www.facebook.com/ikbal.rifat.5
       */

      /* ll dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
      /* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
      /* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
      /* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction

}


#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define ulli  unsigned ll int
#define sl(n) scanf("%lld", &n)
#define sl2(a,b) scanf("%lld%lld", &a,&b)
#define sl3(a,b,c) scanf("%lld%lld%lld", &a,&b,&c)
#define VI  vector<int>
#define Vll  vector<ll>
#define   all(v)  v.begin(),v.end()
#define ub(v,x)  upper_bound(all(v),x)

bool check(int x,int pos){return  (bool)(x &(1<<pos));}
int st(int x,int pos){  return x= x |(1<<pos);}
int  Reset(int x,int pos ){ return x= x &~(1<<pos);}

#define si(n) scanf("%d", &n)
#define si2(a,b) scanf("%d%d", &a,&b)
#define si3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define sf(n) scanf("%lf", &n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define mkpr  make_pair
#define   ff   first
#define   ss  second
#define  srt(V)  sort(V.begin(),V.end());
#define nl printf("\n");
#define  PI  2*acos(0.0);
#define  INFP ((ll)1<<62)
#define  INFN (0-(ll)1<<62)
#define  loop(a,b)  for(int g=a;g<=b;g++)
#define  for1(n)  for(int i=0;i<n;i++)
#define  for2(n)  for(int j=0;j<n;j++)
#define  for3(n)  for(int k=0;k<n;k++)
#define  for4(n)  for(int l=0;l<n;l++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define  bug1(a)  cout<<a<<endl;
#define  bug2(a,b)  cout<<a<<" "<<b<<endl;
#define  bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
#define  bug4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define  tst(n)  for(int cs=1;cs<=n;cs++)
#define spc <<" "<<
#define  pys puts("YES");
#define  pno  puts("NO");
#define bug puts("bug");
#define  pmn puts("-1");
#define zero puts("0");
#define limit 200006
#define md 1000000007

typedef pair<ll,ll> iPair;

//map<ll,set<ll> >mp;

ll A[limit];
ll dp[limit];

int main()
{
      memset(dp,0,sizeof dp);
          /*
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);*/

       ll n;

       cin>>n;
       set<iPair>mp;

       for(int i=1;i<=n;i++)
       {

        sl(A[i]);
        mp.insert({A[i],i});

       }

       ll mx=0,st,s,z,c;

       for(ll i=1;i<=n;i++)
       {
           s=A[i];
           z=i;
           Vll keep;
           keep.pb(z);
           auto it=mp.upper_bound({s+1,z});

           if(dp[i])continue;
           ll vl=0;

          while(it!=mp.end())
          {

             if(it->ss<z||it->ff!=(s+1))
              {

                  break;
              }

            z=it->ss;
            vl=dp[z];
            if(dp[z])break;
            keep.pb(z);
            s=A[z];

            it=mp.upper_bound({s+1,z});
          }

        for(int i=keep.size()-1;i>=0;i--)
        {

          dp[keep[i]]=keep.size()-i+vl;
        }

        if(mx<dp[i])
        {

          mx=dp[i];
          st=i;
        }

       }

       cout<<mx<<endl;

        s=A[st];

        for(int i=st;i<=n;i++)
        {

          if(A[i]==s)
          {
            cout<<i<<" ";
              s++;

          }
        }

        nl

        /**
       *    @author     : Ikbal Hossain
       *    @University  : RUET CSE 15
       *    @CodeForces : iAmrifat
       *    @UVA        : rifat_ikbal
       *    @facebook   : https://www.facebook.com/ikbal.rifat.5
       */

      /* ll dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
      /* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
      /* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
      /* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction

}


#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define ulli  unsigned ll int
#define sl(n) scanf("%lld", &n)
#define sl2(a,b) scanf("%lld%lld", &a,&b)
#define sl3(a,b,c) scanf("%lld%lld%lld", &a,&b,&c)
#define VI  vector<int>
#define Vll  vector<ll>
#define   all(v)  v.begin(),v.end()
#define ub(v,x)  upper_bound(all(v),x)

bool check(int x,int pos){return  (bool)(x &(1<<pos));}
int st(int x,int pos){  return x= x |(1<<pos);}
int  Reset(int x,int pos ){ return x= x &~(1<<pos);}

#define si(n) scanf("%d", &n)
#define si2(a,b) scanf("%d%d", &a,&b)
#define si3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define sf(n) scanf("%lf", &n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define mkpr  make_pair
#define   ff   first
#define   ss  second
#define  srt(V)  sort(V.begin(),V.end());
#define nl printf("\n");
#define  PI  2*acos(0.0);
#define  INFP ((ll)1<<62)
#define  INFN (0-(ll)1<<62)
#define  loop(a,b)  for(int g=a;g<=b;g++)
#define  for1(n)  for(int i=0;i<n;i++)
#define  for2(n)  for(int j=0;j<n;j++)
#define  for3(n)  for(int k=0;k<n;k++)
#define  for4(n)  for(int l=0;l<n;l++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define  bug1(a)  cout<<a<<endl;
#define  bug2(a,b)  cout<<a<<" "<<b<<endl;
#define  bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
#define  bug4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define  tst(n)  for(int cs=1;cs<=n;cs++)
#define spc <<" "<<
#define  pys puts("YES");
#define  pno  puts("NO");
#define bug puts("bug");
#define  pmn puts("-1");
#define zero puts("0");
#define limit 200006
#define md 1000000007

typedef pair<ll,ll> iPair;

map<ll,set<ll> >mp;

ll A[limit];
bool visited[limit];

int main()
{
      memset(visited,0,sizeof visited);

       /*freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);*/

       ll n;

       cin>>n;
       set<iPair>mp;

       for(int i=1;i<=n;i++)
       {

        sl(A[i]);
        mp.insert({A[i],i});

        //mp[A[i]].insert(i);

       }

       ll mx=0,st,s,z,c;

       for(int i=1;i<=n;i++)
       {
           s=A[i];
           z=i,c=1;

          if(visited[z])continue;
          visited[z]=true;
        while(mp.upper_bound({s+1,z})!=mp.end())
        {

          auto it=mp.upper_bound({s+1,z});

          if(it->ss<z||it->ff!=(s+1))
          {

              break;
          }

          z=it->ss;
          visited[z]=true;

          s=A[z];

        c++;
        }

        //mx=max(mx,c);
        if(mx<c)
        {

          mx=c;
          st=i;
        }

       }

       cout<<mx<<endl;

        s=A[st];
       z=st;
        printf("%lld ",z);

       while(mp.upper_bound({s+1,z})!=mp.end())
        {

          auto it=mp.upper_bound({s+1,z});

          if(it->ss<z||it->ff!=(s+1))
          {

              break;
          }

          z=it->ss;

          printf("%lld ",z);
          s=A[z];

        }
        nl

        /**
       *    @author     : Ikbal Hossain
       *    @University  : RUET CSE 15
       *    @CodeForces : iAmrifat
       *    @UVA        : rifat_ikbal
       *    @facebook   : https://www.facebook.com/ikbal.rifat.5
       */

      /* ll dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
      /* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
      /* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
      /* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction

}


#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define ulli  unsigned ll int
#define sl(n) scanf("%lld", &n)
#define sl2(a,b) scanf("%lld%lld", &a,&b)
#define sl3(a,b,c) scanf("%lld%lld%lld", &a,&b,&c)
#define VI  vector<int>
#define Vll  vector<ll>
#define   all(v)  v.begin(),v.end()
#define ub(v,x)  upper_bound(all(v),x)

bool check(int x,int pos){return  (bool)(x &(1<<pos));}
int st(int x,int pos){  return x= x |(1<<pos);}
int  Reset(int x,int pos ){ return x= x &~(1<<pos);}

#define si(n) scanf("%d", &n)
#define si2(a,b) scanf("%d%d", &a,&b)
#define si3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define sf(n) scanf("%lf", &n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define mkpr  make_pair
#define   ff   first
#define   ss  second
#define  srt(V)  sort(V.begin(),V.end());
#define nl printf("\n");
#define  PI  2*acos(0.0);
#define  INFP ((ll)1<<62)
#define  INFN (0-(ll)1<<62)
#define  loop(a,b)  for(int g=a;g<=b;g++)
#define  for1(n)  for(int i=0;i<n;i++)
#define  for2(n)  for(int j=0;j<n;j++)
#define  for3(n)  for(int k=0;k<n;k++)
#define  for4(n)  for(int l=0;l<n;l++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define  bug1(a)  cout<<a<<endl;
#define  bug2(a,b)  cout<<a<<" "<<b<<endl;
#define  bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
#define  bug4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define  tst(n)  for(int cs=1;cs<=n;cs++)
#define spc <<" "<<
#define  pys puts("YES");
#define  pno  puts("NO");
#define bug puts("bug");
#define  pmn puts("-1");
#define zero puts("0");
#define limit 200006
#define md 1000000007

typedef pair<ll,ll> iPair;

//map<ll,set<ll> >mp;

ll A[limit];
ll dp[limit];

int main()
{
      memset(dp,0,sizeof dp);

       /*freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);*/

       ll n;

       cin>>n;
       set<iPair>mp;

       for(int i=1;i<=n;i++)
       {

        sl(A[i]);
        mp.insert({A[i],i});

       }

       ll mx=0,st,s,z,c;

       for(ll i=1;i<=n;i++)
       {
           s=A[i];
           z=i;
           Vll keep;
           keep.pb(z);
           auto it=mp.upper_bound({s+1,z});

           if(dp[i])continue;

          while(it!=mp.end())
          {

             if(it->ss<z||it->ff!=(s+1))
              {

                  break;
              }

            z=it->ss;
            keep.pb(z);
            s=A[z];

            it=mp.upper_bound({s+1,z});
          }

        for(int i=keep.size()-1;i>=0;i--)
        {

          dp[keep[i]]=keep.size()-i;
        }

        if(mx<dp[i])
        {

          mx=dp[i];
          st=i;
        }

       }

       cout<<mx<<endl;

        s=A[st];

        for(int i=st;i<=n;i++)
        {

          if(A[i]==s)
          {
            cout<<i<<" ";
              s++;

          }
        }

        nl

        /**
       *    @author     : Ikbal Hossain
       *    @University  : RUET CSE 15
       *    @CodeForces : iAmrifat
       *    @UVA        : rifat_ikbal
       *    @facebook   : https://www.facebook.com/ikbal.rifat.5
       */

      /* ll dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
      /* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
      /* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
      /* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction

}


#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define ulli  unsigned ll int
#define sl(n) scanf("%lld", &n)
#define sl2(a,b) scanf("%lld%lld", &a,&b)
#define sl3(a,b,c) scanf("%lld%lld%lld", &a,&b,&c)
#define VI  vector<int>
#define Vll  vector<ll>
#define   all(v)  v.begin(),v.end()
#define ub(v,x)  upper_bound(all(v),x)

bool check(int x,int pos){return  (bool)(x &(1<<pos));}
int st(int x,int pos){  return x= x |(1<<pos);}
int  Reset(int x,int pos ){ return x= x &~(1<<pos);}

#define si(n) scanf("%d", &n)
#define si2(a,b) scanf("%d%d", &a,&b)
#define si3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define sf(n) scanf("%lf", &n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define mkpr  make_pair
#define   ff   first
#define   ss  second
#define  srt(V)  sort(V.begin(),V.end());
#define nl printf("\n");
#define  PI  2*acos(0.0);
#define  INFP ((ll)1<<62)
#define  INFN (0-(ll)1<<62)
#define  loop(a,b)  for(int g=a;g<=b;g++)
#define  for1(n)  for(int i=0;i<n;i++)
#define  for2(n)  for(int j=0;j<n;j++)
#define  for3(n)  for(int k=0;k<n;k++)
#define  for4(n)  for(int l=0;l<n;l++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define  bug1(a)  cout<<a<<endl;
#define  bug2(a,b)  cout<<a<<" "<<b<<endl;
#define  bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
#define  bug4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define  tst(n)  for(int cs=1;cs<=n;cs++)
#define spc <<" "<<
#define  pys puts("YES");
#define  pno  puts("NO");
#define bug puts("bug");
#define  pmn puts("-1");
#define zero puts("0");
#define limit 200006
#define md 1000000007

typedef pair<ll,ll> iPair;

map<ll,set<ll> >mp;

ll A[limit];
bool visited[limit];

int main()
{
      memset(visited,0,sizeof visited);

  /*     freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
*/

       ll n;

       cin>>n;

       for(int i=1;i<=n;i++)
       {

        sl(A[i]);
        mp[A[i]].insert(i);

       }

       ll mx=0,st,s,z,c;

       for(int i=1;i<=n;i++)
       {
           s=A[i];
           z=i,c=1;

          if(visited[z])continue;
          visited[z]=true;
        while(mp[s+1].upper_bound(z)!=mp[s+1].end())
        {

          auto it=mp[s+1].upper_bound(z);

          if(*it<z)
          {

              break;
          }

          z=*it;
          visited[z]=true;

          s=A[z];

        c++;
        }

        //mx=max(mx,c);
        if(mx<c)
        {

          mx=c;
          st=i;
        }

       }

       cout<<mx<<endl;

        s=A[st];
       z=st;
       cout<<st<<" ";

       while(mp[s+1].upper_bound(z)!=mp[s+1].end())
        {

          auto it=mp[s+1].upper_bound(z);

          if(*it<z)
          {

              break;
          }

          z=*it;

         printf("%lld ",z);
          visited[z]=true;

          s=A[z];

        c++;
        }
        nl

        /**
       *    @author     : Ikbal Hossain
       *    @University  : RUET CSE 15
       *    @CodeForces : iAmrifat
       *    @UVA        : rifat_ikbal
       *    @facebook   : https://www.facebook.com/ikbal.rifat.5
       */

      /* ll dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
      /* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
      /* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
      /* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction

}


#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define ulli  unsigned ll int
#define sl(n) scanf("%lld", &n)
#define sl2(a,b) scanf("%lld%lld", &a,&b)
#define sl3(a,b,c) scanf("%lld%lld%lld", &a,&b,&c)
#define VI  vector<int>
#define Vll  vector<ll>
#define   all(v)  v.begin(),v.end()
#define ub(v,x)  upper_bound(all(v),x)

bool check(int x,int pos){return  (bool)(x &(1<<pos));}
int st(int x,int pos){  return x= x |(1<<pos);}
int  Reset(int x,int pos ){ return x= x &~(1<<pos);}

#define si(n) scanf("%d", &n)
#define si2(a,b) scanf("%d%d", &a,&b)
#define si3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define sf(n) scanf("%lf", &n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define mkpr  make_pair
#define   ff   first
#define   ss  second
#define  srt(V)  sort(V.begin(),V.end());
#define nl printf("\n");
#define  PI  2*acos(0.0);
#define  INFP ((ll)1<<62)
#define  INFN (0-(ll)1<<62)
#define  loop(a,b)  for(int g=a;g<=b;g++)
#define  for1(n)  for(int i=0;i<n;i++)
#define  for2(n)  for(int j=0;j<n;j++)
#define  for3(n)  for(int k=0;k<n;k++)
#define  for4(n)  for(int l=0;l<n;l++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define  bug1(a)  cout<<a<<endl;
#define  bug2(a,b)  cout<<a<<" "<<b<<endl;
#define  bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
#define  bug4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define  tst(n)  for(int cs=1;cs<=n;cs++)
#define spc <<" "<<
#define  pys puts("YES");
#define  pno  puts("NO");
#define bug puts("bug");
#define  pmn puts("-1");
#define zero puts("0");
#define limit 200006
#define md 1000000007

typedef pair<ll,ll> iPair;

//map<ll,set<ll> >mp;

ll A[limit];
bool visited[limit];

int main()
{
      memset(visited,0,sizeof visited);

/*       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);*/

       ll n;

       cin>>n;
       set<iPair>mp;

       for(int i=1;i<=n;i++)
       {

        sl(A[i]);
        mp.insert({A[i],i});

        //mp[A[i]].insert(i);

       }

       ll mx=0,st,s,z,c;

       for(ll i=1;i<=n;i++)
       {
           s=A[i];
           z=i,c=1;

          if(visited[z])continue;

          visited[z]=true;
          auto it=mp.upper_bound({s+1,z});
        while(it!=mp.end())
        {

          if(it->ss<z||it->ff!=(s+1))
          {

              break;
          }

          z=it->ss;
          visited[z]=true;

          s=A[z];

        c++;

        it=mp.upper_bound({s+1,z});
        }

        //mx=max(mx,c);
        if(mx<c)
        {

          mx=c;
          st=i;
        }

       }

       cout<<mx<<endl;

        s=A[st];

        for(int i=st;i<=n;i++)
        {

          if(A[i]==s)
          {
            cout<<i<<" ";
              s++;

          }
        }

        nl

        /**
       *    @author     : Ikbal Hossain
       *    @University  : RUET CSE 15
       *    @CodeForces : iAmrifat
       *    @UVA        : rifat_ikbal
       *    @facebook   : https://www.facebook.com/ikbal.rifat.5
       */

      /* ll dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
      /* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
      /* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
      /* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction

}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0) ;
	cout.tie(0) ;
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
	int mx = 0 , si = 0 ;
	vector<int> vis(n) ;
	vector<int> mem(n) ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[i] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			if(vis[*it]){
				sz+= mem[*it];
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li) ;
			vis[li]= 1 ;
		}
	for(int j=0;j<p.size();j++)mem[p[j]] = p.size()-j;
			if(mx<sz){mx=sz,si=i;};
	}

	cout << mx << endl ;
	int tgt = a[si];
	for(;si<n;si++){
		if(a[si]== tgt){
			cout << si+1<<" " ;
			tgt++;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0) ;
	cout.tie(0) ;
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	unordered_map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
	int mx = 0 , si = 0 ;
	vector<int> ans ;
	unordered_map<int,int> vis ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[a[i]] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i+1) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li+1) ;
			vis[tgt] = 1 ;
		}
			if(mx<sz){mx=sz,si=a[i],ans=p; }
	}
	cout << ans.size() << endl ;
	for(int x : ans) cout << x << " "  ;
	return 0;
}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0) ;
	cout.tie(0) ;
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
	int mx = 0 , si = 0 ;
	vector<int> vis(n) ;
	vector<int> mem(n) ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[i] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			if(vis[*it]){
				sz+= mem[*it];
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li) ;
			vis[li]= 1 ;
		}
		 for(int j=0;j<p.size();j++)mem[p[j]] = sz-p.size()+p.size()-j;
			if(mx<sz){mx=sz,si=i;};
	}

	cout << mx << endl ;
	int tgt = a[si];
	for(;si<n;si++){
		if(a[si]== tgt){
			cout << si+1<<" " ;
			tgt++;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
//	vector<int> vis(n);
	int mx = 0 , si = 0 ;
	vector<int> ans ;
	map<int,int> vis ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[a[i]] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i+1) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li+1) ;
			vis[tgt] = 1 ;
		}
			if(mx<sz){mx=sz,si=a[i],ans=p; }
	}
	cout << ans.size() << endl ;
	for(int x : ans) cout << x << " "  ;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout) ;
	#endif
	int n ;
	cin>>n ;
	vector<int> a(n) ;
	int i  = 0;
	map<int,multiset<int>> m ;
	for(int& x : a){
		cin>> x;
		m[x].insert(i) ;
		i++;
	}
	map<int,int> vis ;
	vector<int> ans ;
	for(int i=0;i<n;i++){
		if(vis[a[i]]) continue;
		int li = i,tgt = a[i] ;
		vector<int> pans ;
		pans.push_back(i+1) ;
		while(1){
			tgt++;
			auto it = m[tgt].lower_bound(li) ;
			if(it == m[tgt].end()) break ;
			vis[tgt]= 1 ;
			li = *it ;
			pans.push_back(li+1) ;
		}
		if(ans.size()<pans.size()) ans = pans ;
	}
	cout << ans.size() << endl ;
	for(auto it : ans) cout << it << " " ;
	return 0 ;
}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	unordered_map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
	int mx = 0 , si = 0 ;
	vector<int> ans ;
	unordered_map<int,int> vis ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[a[i]] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i+1) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li+1) ;
			vis[tgt] = 1 ;
		}
			if(mx<sz){mx=sz,si=a[i],ans=p; }
	}
	cout << ans.size() << endl ;
	for(int x : ans) cout << x << " "  ;
	return 0;
}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	unordered_map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
	vector<int> vis(n);
	int mx = 0 , si = 0 ;
	vector<int> ans ;
	unordered_map<int,int> vis ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[a[i]] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i+1) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li+1) ;
			vis[tgt] = 1 ;
		}
			if(mx<sz){mx=sz,si=a[i],ans=p; }
	}
	cout << ans.size() << endl ;
	for(int x : ans) cout << x << " "  ;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout) ;
	#endif
	int n ;
	cin>>n ;
	vector<int> a(n) ;
	int i  = 0;
	map<int,multiset<int>> m ;
	for(int& x : a){
		cin>> x;
		m[x].insert(i) ;
		i++;
	}
	map<int,int> vis ;
	vector<int> ans ;
	for(int i=0;i<n;i++){
		if(vis[a[i]]) continue;
		int li = i,tgt = a[i] ;
		vector<int> pans ;
		pans.push_back(tgt) ;
		while(1){
			tgt++;
			auto it = m[tgt].lower_bound(li) ;
			if(it == m[tgt].end()) break ;
			vis[tgt]= 1 ;
			li = *it ;
			pans.push_back(tgt) ;
		}
		if(ans.size()<pans.size()) ans = pans ;
	}
	cout << ans.size() << endl ;
	for(auto it : ans) cout << it << " " ;
	return 0 ;
}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0) ;
	cout.tie(0) ;
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
	int mx = 0 , si = 0 ;
	vector<int> vis(n) ;
	vector<int> mem(n) ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[i] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i+1) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			if(vis[*it]){
				sz+= mem[*it];
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li+1) ;
			vis[li]= 1 ;
		}
	for(int j=0;j<p.size();j++)mem[p[j]] = p.size()-j;
			if(mx<sz){mx=sz,si=i;};
	}

	cout << mx << endl ;
	int tgt = a[si];
	for(;si<n;si++){
		if(a[si]== tgt){
			cout << si+1<<" " ;
			tgt++;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0) ;
	cout.tie(0) ;
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	_map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
	int mx = 0 , si = 0 ;
	vector<int> ans ;
	vector<int> vis(n) ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[i] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i+1) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li+1) ;
			vis[li]= 1 ;
		}
			if(mx<sz){mx=sz,si=a[i],ans=p; }
	}
	cout << ans.size() << endl ;
	for(int x : ans) cout << x << " "  ;
	return 0;
}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0) ;
	cout.tie(0) ;
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
	int mx = 0 , si = 0 ;
	vector<int> ans ;
	vector<int> vis(n) ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[i] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i+1) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li+1) ;
			vis[li]= 1 ;
		}
			if(mx<sz){mx=sz,si=a[i],ans=p; }
	}
	cout << ans.size() << endl ;
	for(int x : ans) cout << x << " "  ;
	return 0;
}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
	vector<int> vis(n);
	int mx = 0 , si = 0 ;
	vector<int> ans  ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[i] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i+1) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li+1) ;
			vis[li] = 1 ;
		}
			if(mx<sz){mx=sz,si=a[i],ans=p; }
	}
	cout << ans.size() << endl ;
	for(int x : ans) cout << x << " "  ;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout) ;
	#endif
	int n ;
	cin>>n ;
	vector<int> a(n) ;
	int i  = 0;
	map<int,multiset<int>> m ;
	for(int& x : a){
		cin>> x;
		m[x].insert(i) ;
		i++;
	}
	map<int,int> vis ;
	vector<int> ans ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue;
		int li = i,tgt = a[i] ;
		vector<int> pans ;
		pans.push_back(i+1) ;
		vis[i]=1;
		while(1){
			tgt++;
			auto it = m[tgt].lower_bound(li) ;
			if(it == m[tgt].end()) break ;
			vis[*it]= 1 ;
			li = *it ;
			pans.push_back(li+1) ;
		}
		if(ans.size()<pans.size()) ans = pans ;
	}
	cout << ans.size() << endl ;
	for(auto it : ans) cout << it << " " ;
	return 0 ;
}


#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0) ;
	cout.tie(0) ;
	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin) ;
		freopen("out.txt","w",stdout);
	#endif
	int n ;
	map<int,vector<int>> m;
	cin>>n ;vector<int> a(n); int i= 0; for(int& x : a){cin>>x;m[x].push_back(i);++i;}
	int mx = 0 , si = 0 ;
	vector<int> vis(n) ;
	vector<int> mem(n) ;
	for(int i=0;i<n;i++){
		if(vis[i]) continue ;
		vis[i] = 1 ;
		int li  = i,tgt =a[i];
		int sz =1 ;
		vector<int> p ;
		p.push_back(i+1) ;
		while(1){
			tgt++;
			auto it = lower_bound(all(m[tgt]),li);
			if(it == m[tgt].end()){
				break ;
			}
			if(vis[*it]){
				sz+= mem[*it];
				break ;
			}
			sz++;
			li = *it ;
			p.push_back(li) ;
			vis[li]= 1 ;
		}
	for(int j=0;j<p.size();j++)mem[p[j]] = p.size()-j;
			if(mx<sz){mx=sz,si=i;};
	}

	cout << mx << endl ;
	int tgt = a[si];
	for(;si<n;si++){
		if(a[si]== tgt){
			cout << si+1<<" " ;
			tgt++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<ll,int>>v;
int check[300000];
ll a[300000];
int main()
{
    int n;
    cin>>n;
      for(int i=1;i<=n;i++)
      {
          cin>>a[i];
          v.push_back(make_pair(a[i],i));
      }
      sort(v.begin(),v.end());

    int len=1;
    check[1]=0;
    int cnt=1;

        for( int i=1;i<v.size();i++)
        {
            if(v[i].first==(v[i-1].first+1) && v[i].second>v[i-1].second)
            {
                cnt++;
            }
            else
            {

                cnt=1;
            }

            check[cnt]=i;

            if(n==200000)
            {
               if(v[i].second==5246)
               {
                   cout<<cnt<<" "<<i<<endl;
               }
            }
        }

            for(int i=n;i>=1;i--)
            {
                if(check[i]!=0)
                {
                    cout<<i<<endl;
                    for(int y=(check[i]-i+1);y<(check[i]+1);y++)
                    {
                        cout<<v[y].second<<" ";
                    }
                    return 0;
                }
            }

    return 0;
}