#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 5;
map<int, int> m;
int a[N];
int res[N];
int main() {
  int n;
  scanf("%d", &n);
  int e, v;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &v);
    a[i] = v;
    m[v] = m[v - 1] + 1;
    if (ans < m[v]) {
      ans = m[v];
      e = i;
    }
  }
  printf("%d\n", ans);
  int tot = 0;
  int flag = a[e];
  for (int i = e; i >= 0; i--) {
    if (a[i] == flag) {
      res[tot++] = i + 1;
      flag--;
    }
    if (tot == ans) break;
  }
  for (int i = tot - 1; i > 0; i--) {
    printf("%d ", res[i]);
  }
  printf("%d\n", res[0]);
  return 0;
}
