#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, a[N];
int mx, ans;
map<int, int> dp;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    dp[a[i]] = max(dp[a[i]], dp[a[i] - 1] + 1);
    if (dp[a[i]] > mx) mx = dp[a[i]], ans = a[i];
  }
  printf("%d\n", mx);
  stack<int> st;
  for (int i = n - 1; ~i; --i)
    if (a[i] == ans) st.push(i + 1), --ans;
  while (st.size()) printf("%d ", st.top()), st.pop();
  return 0;
}
