#include <bits/stdc++.h>
using namespace std;
int n, a[200005];
map<int, int> mmp;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mmp[a[i]] = mmp[a[i] - 1] + 1;
  }
  map<int, int>::iterator it;
  int maxi = -1;
  int pos;
  for (it = mmp.begin(); it != mmp.end(); it++) {
    if (maxi < it->second) {
      maxi = it->second;
      pos = it->first;
    }
  }
  cout << maxi << endl;
  pos = pos - maxi + 1;
  for (int i = 0; i < n; i++) {
    if (a[i] == pos) {
      cout << i + 1 << ' ';
      pos++;
    }
  }
  cout << endl;
  return 0;
}
