#include <bits/stdc++.h>
using namespace std;
int const N = 2e5 + 10;
int a[N];
map<int, vector<int>> mp;
vector<int> opt, t;
int vis[N];
pair<int, int> h[N];
void dfs(int i) {
  vis[i] = 1;
  t.push_back(i);
  vector<int>::iterator x =
      upper_bound((mp[a[i] + 1]).begin(), (mp[a[i] + 1]).end(), i);
  if (x != mp[a[i] + 1].end() and vis[*x] == 0) dfs(*x);
}
int main() {
  ios_base::sync_with_stdio(0);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    h[i].first = a[i];
    h[i].second = i;
    mp[a[i]].push_back(i);
  }
  sort(h, h + n);
  for (int i = 0; i < n; i++) {
    if (vis[h[i].second] == 0) {
      dfs(h[i].second);
      if (opt.size() < t.size()) opt = t;
      t.clear();
    }
  }
  cout << opt.size() << endl;
  for (auto i : opt) cout << i + 1 << " ";
}
