#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, i, j, n, k;
  cin >> n;
  long long a[n + 1], mx = 0, value;
  map<long long, long long> mp;
  vector<long long> v;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]] = max(mp[a[i]], mp[a[i] - 1] + 1);
    if (mx < mp[a[i]]) {
      value = a[i];
      mx = mp[a[i]];
    }
  }
  for (i = n; i >= 1; i--) {
    if (value == a[i]) {
      v.push_back(i);
      value--;
    }
  }
  cout << mx << endl;
  for (i = v.size() - 1; i >= 0; i--) cout << v[i] << " ";
}
