#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
int main() {
  long long a, mx = 0, k = 1e17 + 5;
  cin >> a;
  long long f[a];
  for (int g = 0; g < a; g++) cin >> f[g];
  for (int g = 0; g < a; g++) {
    mp[f[g]] = mp[f[g] - 1] + 1;
    mx = max(mp[f[g]], mx);
  }
  cout << mx << endl;
  vector<long long> v;
  for (int g = a - 1; g >= 0; g--) {
    if (mp[f[g]] == mx) {
      mx = -100000;
      k = f[g] - 1;
      v.push_back(g);
    }
    if (f[g] == k) {
      v.push_back(g);
      k--;
    }
  }
  for (int g = v.size() - 1; g >= 0; g--) cout << v[g] + 1 << ' ';
}
