#include <bits/stdc++.h>
using namespace std;
inline int Gcd(int X, int Y) { return Y ? Gcd(Y, X % Y) : X; }
inline long long Gcd(long long X, long long Y) { return Y ? Gcd(Y, X % Y) : X; }
inline int Pow(int base, long long exp, int _mod) {
  if (!(base %= _mod)) return 0;
  int _ans = 1;
  for (; exp; exp >>= 1, base = (long long)base * base % _mod)
    exp& 1 ? _ans = (long long)_ans * base % _mod : 0;
  return _ans;
}
inline long long Pow(long long base, long long exp, long long _mod) {
  if (!(base %= _mod)) return 0;
  long long _ans = 1;
  for (; exp; exp >>= 1, base = base * base % _mod)
    exp& 1 ? _ans = _ans * base % _mod : 0;
  return _ans;
}
const int INF = 0x3f3f3f3f;
int n, q;
int a[200001];
map<int, int> Mp;
int Ans[200001], t;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= (n); ++i) scanf("%d", a + i);
  for (int i = 1; i <= (n); ++i) {
    if (!Mp.count(a[i])) Mp[a[i]] = 1;
    if (Mp.count(a[i] - 1)) Mp[a[i]] = max(Mp[a[i]], Mp[a[i] - 1] + 1);
  }
  int ans = a[1];
  for (int i = 2; i <= (n); ++i)
    if (Mp[ans] < Mp[a[i]]) ans = a[i];
  t = Mp[ans];
  int At = t;
  for (int i = n; i >= (1); --i)
    if (a[i] == ans) Ans[t--] = i, --ans;
  printf("%d\n", At);
  for (int i = 1; i <= (At); ++i) printf("%d ", Ans[i]);
  return 0;
}
