#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    if (m.find(arr[i] - 1) == m.end()) {
      m[arr[i]] = 1;
    } else {
      m[arr[i]] = m[arr[i] - 1] + 1;
    }
  }
  map<long long, long long>::iterator it;
  long long maxlen = 0, val;
  for (it = m.begin(); it != m.end(); it++) {
    maxlen = max(maxlen, it->second);
    if (maxlen == it->second) val = it->first;
  }
  cout << maxlen << endl;
  long long startfrom = val - maxlen + 1;
  for (long long i = 0; i < n; i++) {
    if (startfrom == arr[i] and startfrom == val) {
      cout << i + 1 << endl;
      break;
    } else if (arr[i] == startfrom) {
      cout << i + 1 << " ";
      startfrom++;
    }
  }
}
