#include <bits/stdc++.h>
using namespace std;
int a[200005];
int MAX(int a, int b) { return a > b ? a : b; }
int main() {
  int n, m, len;
  while (~scanf("%d", &n)) {
    map<int, int> dp;
    len = -1;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      dp[a[i]] = MAX(dp[a[i] - 1] + 1, dp[a[i]]);
      if (dp[a[i]] > len) {
        len = dp[a[i]];
        m = a[i];
      }
    }
    cout << len << endl;
    int s = m - len + 1, t = s;
    for (int i = 0; i < n; i++) {
      if (a[i] == s) {
        if (s == t)
          cout << i + 1;
        else
          cout << " " << i + 1;
        s++;
      }
    }
    cout << endl;
  }
  return 0;
}
