#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int dp[N], arr[N];
map<int, vector<int>> mop;
int getIndex(int j) {
  if (mop[arr[j] - 1].empty()) return -1;
  int l = 0, r = mop[arr[j] - 1].size() - 1, mid, ret = -1;
  vector<int> v = mop[arr[j] - 1];
  while (l <= r) {
    mid = (l + r) / 2;
    if (v[mid] < j)
      l = mid + 1, ret = v[mid];
    else
      r = mid - 1;
  }
  return ret;
}
int go(int indx) {
  int &ret = dp[indx];
  if (~ret) return ret;
  int i = getIndex(indx);
  if (~i)
    return ret = 1 + go(i);
  else
    return ret = 1;
}
void p(int indx) {
  int i = getIndex(indx);
  if (~i) p(i);
  cout << indx + 1 << " ";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i], mop[arr[i]].push_back(i);
  memset(dp, -1, sizeof dp);
  go(0);
  for (int i = n - 1; i >= 0; i--) ans = max(ans, go(i));
  cout << ans << endl;
  for (int i = n - 1; i >= 0; i--)
    if (ans == dp[i]) {
      p(i);
      break;
    }
  return 0;
}
