#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  map<long long, long long> ans;
  long long ret = 0;
  map<long long, long long> idx;
  for (int i = 0; i < n; i++) {
    ans[ar[i]] = ans[ar[i] - 1] + 1;
    ret = max(ret, ans[ar[i]]);
    if (idx.find(ar[i]) == idx.end()) {
      idx[ar[i]] = i;
    }
  }
  long long x;
  for (auto u : ans) {
    if (u.second == ret) {
      x = u.first;
      break;
    }
  }
  cout << ret << '\n';
  long long st = x - ret + 1;
  vector<long long> vr;
  for (int i = 0; i < n; i++) {
    if (st > x) break;
    if (ar[i] == st) {
      st++;
      vr.push_back(i + 1);
    }
  }
  for (auto u : vr) {
    cout << u << " ";
  }
  return 0;
}
