#include <bits/stdc++.h>
using namespace std;
inline int I() {
  int s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * f;
}
const int inf = 1e9;
const int N = 2e5 + 5;
int n, a[N], ne[N], sum[N], ans, id, sta[N], top;
map<int, int> q;
int main() {
  n = I();
  for (int i = 1; i <= n; ++i) {
    a[i] = I();
    if (q[a[i] - 1] != 0) ne[i] = q[a[i] - 1];
    q[a[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    int ls = 0;
    for (int x = i; x; x = ne[x])
      if (!sum[x])
        ls++;
      else {
        ls += sum[x];
        break;
      }
    for (int x = i; x; x = ne[x], --ls)
      if (!sum[x])
        sum[x] = ls;
      else
        break;
    if (ans < sum[i]) {
      ans = sum[i];
      id = i;
    }
  }
  printf("%d\n", ans);
  for (int x = id; x; x = ne[x]) sta[++top] = x;
  for (int i = top; i >= 1; --i) printf("%d ", sta[i]);
  return 0;
}
