#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long int a[n], x;
  for (int i = 0; i < n; i++) scanf("%lld ", &a[i]);
  map<long long int, long long int> mp;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    mp[a[i]] = max(mp[a[i]], mp[a[i] - 1] + 1);
    if (ans < mp[a[i]]) {
      x = a[i];
      ans = mp[a[i]];
    }
  }
  printf("%lld\n", ans);
  x = x - ans + 1;
  for (int i = 0; i < n; i++) {
    if (a[i] == x) {
      cout << i + 1 << " ";
      x++;
    }
  }
}
