#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2e5 + 100;
int n, a[Maxn];
int dp[Maxn];
int cha[Maxn];
map<int, int> m;
struct node {
  int x, id;
} g[Maxn];
bool cmp(struct node a, struct node b) { return a.x < b.x; }
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n) {
    memset(cha, 0, sizeof(cha));
    m.clear();
    int len = -1, ans = -1, id;
    for (int i = 0; i <= n; i++) dp[i] = 1;
    for (int i = 0; i < n; i++) {
      cin >> g[i].x, g[i].id = i + 1;
      int x = g[i].x;
      m[x] = m[x - 1] + 1;
      if (len < m[x]) len = m[x], ans = x;
    }
    int r = ans, l = ans - len + 1;
    cout << len << endl;
    for (int i = 0; i < n; i++) {
      if (g[i].x == l) cout << i + 1 << " ", l++;
    }
    cout << endl;
  }
  return 0;
}
