#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
using namespace std;
bool isvowel(char c) {
  c = tolower(c);
  if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u')
    return 1;
  return 0;
}
const double eps = 0.000001;
const long double pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const long long MOD = 1e18 + 9;
const long long INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;
const int PRI = 555557;
const int pri = 997;
const int Magic = 2101;
int n, m, k;
int a[N];
int Sz = 1;
int p[N];
map<int, pair<int, int> > dp;
inline void Solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  int mx, pos;
  mx = pos = 0;
  for (int i = 1; i <= n; i++) {
    pair<int, int> cur = dp[a[i] - 1];
    p[i] = cur.second;
    cur.first++;
    dp[a[i]] = make_pair(cur.first, i);
    if (cur.first > mx) pos = i, mx = cur.first;
  }
  vector<int> ans;
  while (pos) {
    ans.push_back(pos);
    pos = p[pos];
  }
  reverse(ans.begin(), ans.end());
  printf("%d ", ans.size());
  for (auto it : ans) printf("%d ", it);
}
int main() {
  int tests = 1;
  while (tests--) {
    Solve();
  }
  return 0;
}
