#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e5 + 5, MOD = 1e9 + 7;
int main() {
  map<long long int, long long int> m;
  long long int n;
  cin >> n;
  long long int a[n];
  long long int maxx = 0;
  long long int no;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (m.find(a[i] - 1) == m.end()) {
      m[a[i]] = 1;
    } else
      m[a[i]] = m[a[i] - 1] + 1;
    if (m[a[i]] > maxx) {
      maxx = m[a[i]];
      no = i;
    }
  }
  cout << maxx;
  cout << "\n";
  long long int b = a[no];
  long long int s = b - maxx + 1;
  for (long long int i = 0; i < n; i++) {
    if (s > b) break;
    if (a[i] == s) {
      cout << i + 1 << " ";
      s++;
    }
  }
}
