#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  map<long long, long long> idx, maxlen;
  long long mx = -1, mxidx = -1;
  long long n, x;
  cin >> n;
  vector<long long> v(n + 1);
  for (long long i = 1; i <= n; i++) {
    cin >> x;
    v[i] = x;
    maxlen[x] = maxlen[x - 1] + 1;
    idx[x] = i;
    if (mx < maxlen[x]) {
      mx = maxlen[x];
      mxidx = x;
    }
  }
  long long tochk = mxidx - mx + 1;
  cout << mx << '\n';
  for (long long i = 1; i <= n; i++)
    if (tochk == v[i]) {
      tochk++;
      cout << i << " ";
    }
  return 0;
}
