#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000 * 100 * 2 + 10;
int a[maxN], x[maxN], p[maxN], par[maxN];
pair<int, int> b[maxN], lon[maxN];
void print(int i) {
  if (i == -1) return;
  print(par[i]);
  cout << i + 1 << " ";
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = make_pair(a[i], i);
  }
  sort(b, b + n);
  int l = 0;
  p[b[0].second] = 0;
  x[0] = b[0].first;
  for (int i = 1; i < n; i++) {
    if (b[i].first != b[i - 1].first) l++;
    p[b[i].second] = l;
    x[l] = b[i].first;
  }
  pair<int, int> ans = make_pair(0, -1);
  for (int i = 0; i < n; i++) {
    lon[p[i]].second = i;
    if (p[i] != 0) {
      if (x[p[i] - 1] + 1 == a[i]) {
        lon[p[i]].first = max(lon[p[i] - 1].first + 1, lon[p[i]].first);
        lon[p[i]].second = i;
        par[i] = lon[p[i] - 1].second;
      }
    }
    lon[p[i]].first = max(1, lon[p[i]].first);
    if (lon[p[i]].first == 1) par[i] = -1;
    if (lon[p[i]].first > ans.first) ans = lon[p[i]];
  }
  cout << ans.first << '\n';
  print(ans.second);
}
