#include <bits/stdc++.h>
using namespace std;
const int MAX_LEN = 2e5;
int nums[MAX_LEN];
int best[MAX_LEN];
int previous[MAX_LEN];
int main() {
  int length;
  map<int, int> registry;
  cin >> length;
  int i;
  for (i = 0; i < length; i++) {
    cin >> nums[i];
    previous[i] = -1;
    best[i] = 1;
    auto find = registry.find(nums[i] - 1);
    if (find != registry.end() && find->second < i) {
      best[i] = best[find->second] + 1;
      previous[i] = find->second;
    }
    registry[nums[i]] = i;
  }
  int max = 0;
  int maxIdx = -1;
  for (int i = 0; i < length; i++) {
    maxIdx = best[i] > max ? i : maxIdx;
    max = best[i] > max ? best[i] : max;
  }
  cout << max << endl;
  int iter = maxIdx;
  stack<int> path;
  while (iter != -1) {
    path.push(iter);
    iter = previous[iter];
  }
  while (!path.empty()) {
    cout << path.top() + 1 << " ";
    path.pop();
  }
  cout << endl;
  return 0;
}
