#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
void put1() { puts("Yes"); }
void put2() { puts("No"); }
void put3() { puts("-1"); }
long long qp(long long a, long long b, long long p) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans * a) % p;
      --b;
    }
    a = (a * a) % p;
    b >>= 1;
  }
  return ans % p;
}
const unsigned long long base = 2333;
const unsigned long long pp = 19260811;
const unsigned long long ppp = 999998639;
const int manx = 2e5 + 5;
const int mo = 998244353;
map<long long, long long> dp;
long long a[manx];
vector<long long> q;
int main() {
  long long n = read();
  long long ma = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    dp[a[i]] = max(dp[a[i] - 1] + 1, dp[a[i]]);
    if (dp[a[i]] > ans) ans = dp[a[i]], ma = a[i];
  }
  for (int i = n; i >= 1; i--)
    if (a[i] == ma) q.push_back(i), ma--;
  reverse(q.begin(), q.end());
  cout << q.size() << endl;
  for (auto x : q) cout << x << " ";
  return 0;
}
