#include <bits/stdc++.h>
using namespace std;
int n, t, a[200010], pre[200010], ans = 0, ovo = 0;
map<int, int> f, vis, pos;
int main() {
  memset(pre, -1, sizeof(pre));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
    if (vis[a[i] - 1]) {
      f[pos[a[i]]] = f[pos[a[i] - 1]] + 1;
      pre[i] = pos[a[i] - 1];
    }
    vis[a[i]] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (f[i] > ans) {
      ans = f[i];
      ovo = i;
    }
  }
  stack<int> s;
  while (ovo != -1) {
    s.push(ovo);
    ovo = pre[ovo];
  }
  printf("%d\n", ans + 1);
  if (ans == 0) {
    printf("1\n");
    return 0;
  }
  while (!s.empty()) {
    printf("%d ", s.top());
    s.pop();
  }
}
