#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = std::numeric_limits<long long>::max();
const long long TE3 = 1005;
const long long TE5 = 300005;
const string YN[2] = {"NO", "YES"};
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = (0); i < (n); ++i) cin >> v[i];
  map<long long, pair<long long, long long> > m;
  map<long long, long long> p;
  long long ma = 0, ans = 0;
  long long i = 1;
  for (long long e : v) {
    long long a = m[e].first;
    long long b = m[e - 1].first + 1;
    if (b > a) {
      m[e].first = b;
      m[e].second = i;
      p[i] = m[e - 1].second;
    }
    if (b > ma) {
      ma = b;
      ans = i;
    }
    ++i;
  }
  vector<long long> u;
  u.push_back(ans);
  while (p[ans] != 0) {
    u.push_back(p[ans]);
    ans = p[ans];
  }
  cout << u.size() << endl;
  reverse(u.begin(), u.end());
  for (long long uu : u) {
    cout << uu << " ";
  }
  cout << endl;
  return 0;
}
