#include <bits/stdc++.h>
using namespace std;
int a[200005];
int n;
map<long long, int> dp;
map<long long, vector<int> > v;
int f(int idx) {
  int val = a[idx] - 1;
  while (v[val].size() && v[val].back() >= idx) {
    v[val].pop_back();
  }
  if (v[val].size() == 0) {
    return -1;
  }
  return v[val].back();
}
int main() {
  int ans = 0;
  int idx = -1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v[a[i]].push_back(i);
    int x = a[i];
    dp[x] = 1 + dp[x - 1];
    if (dp[x] > ans) {
      ans = dp[x];
      idx = i;
    }
  }
  cout << ans << endl;
  set<pair<int, int> > s;
  vector<int> res;
  res.clear();
  while (idx != -1) {
    res.push_back(idx + 1);
    idx = f(idx);
  }
  reverse(res.begin(), res.end());
  for (auto x : res) {
    cout << x << " ";
  }
  cout << endl;
}
