#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define faster() ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define maxArr 1000005
void solve() {
int n ; cin >> n ;
int a[n + 1];
map<int, int> dp ;
int ans = 0 , last = 0 ;
for(int i = 0 ; i < n ; i++){
cin >> a[i] ;
dp[a[i]] = max(dp[a[i]], dp[a[i] - 1] + 1 );
// dp[a[i]] = dp[a[i] - 1] + 1 ;
if(dp[a[i]] > ans){
ans = dp[a[i]];
last = a[i] ;
}
}
vector<int> res ;
for(int i = n - 1 ; i >= 0 ; i--){
if(a[i] == last){
res.push_back(i);
--last ;
}
}
reverse(res.begin(), res.end());
cout << ans << endl;
for(int idx : res) cout << idx + 1 << " ";
}
signed main() {
faster();
int test = 1 ;
// cin >> test ;
while(test--) solve();
return 0;
}
CiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZW5kbCAiXG4iCiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIGZhc3RlcigpIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsgY2luLnRpZShudWxscHRyKTsgY291dC50aWUobnVsbHB0cik7CiNkZWZpbmUgbWF4QXJyICAxMDAwMDA1IAp2b2lkIHNvbHZlKCkgewogICAgaW50IG4gOyBjaW4gPj4gbiA7CiAgICBpbnQgYVtuICsgMV07CiAgICBtYXA8aW50LCBpbnQ+IGRwIDsKICAgIGludCBhbnMgPSAwICwgbGFzdCA9IDAgOwogICAgZm9yKGludCBpID0gMCA7IGkgPCBuIDsgaSsrKXsKICAgICAgICBjaW4gPj4gYVtpXSA7CiAgICAgICAgZHBbYVtpXV0gPSBtYXgoZHBbYVtpXV0sIGRwW2FbaV0gLSAxXSArIDEgKTsKICAgICAgICAvLyBkcFthW2ldXSA9ICBkcFthW2ldIC0gMV0gKyAxIDsKICAgICAgICBpZihkcFthW2ldXSA+IGFucyl7CiAgICAgICAgICAgIGFucyA9IGRwW2FbaV1dOwogICAgICAgICAgICBsYXN0ID0gYVtpXSA7CiAgICAgICAgfQogICAgfQogICAgdmVjdG9yPGludD4gcmVzIDsKICAgIGZvcihpbnQgaSA9IG4gLSAxIDsgaSA+PSAwIDsgaS0tKXsKICAgICAgICBpZihhW2ldID09IGxhc3QpewogICAgICAgICAgICByZXMucHVzaF9iYWNrKGkpOwogICAgICAgICAgICAtLWxhc3QgOwogICAgICAgIH0KICAgIH0KICAgIHJldmVyc2UocmVzLmJlZ2luKCksIHJlcy5lbmQoKSk7CiAgICBjb3V0IDw8IGFucyA8PCBlbmRsOwogICAgZm9yKGludCBpZHggOiByZXMpIGNvdXQgPDwgaWR4ICsgMSA8PCAiICI7Cn0KCnNpZ25lZCBtYWluKCkgewogICAgZmFzdGVyKCk7CiAgICBpbnQgdGVzdCA9IDEgOwogICAgLy8gY2luID4+IHRlc3QgOwogICAgd2hpbGUodGVzdC0tKSAgIHNvbHZlKCk7CiAgICByZXR1cm4gMDsKfQoK