#include <bits/stdc++.h>
using namespace std;
int n, k, mx, mi, a[200005];
map<int, int> mp;
int main() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    k = mp[a[i]] = mp[a[i] - 1] + 1;
    if (k > mx) mx = k, mi = a[i];
  }
  printf("%d\n", mx);
  k = mi - mx + 1;
  for (i = 1; i <= n; i++) {
    if (a[i] == k) cout << i << " ", k++;
  }
  return 0;
}
