#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(false);
  std::cout.tie(nullptr);
  std::cin.tie(nullptr);
  int n;
  std::cin >> n;
  std::vector<int> v;
  v.reserve(n);
  for (int i = 0; i < n; ++i) {
    int x;
    std::cin >> x;
    v.push_back(x);
  }
  int ans = 0;
  int end = 0;
  std::map<int, int> dp;
  for (int i = 0; i < v.size(); ++i) {
    int a = v[i];
    int x = dp[a] = dp[a - 1] + 1;
    if (x > ans) {
      end = a;
      ans = x;
    }
  }
  std::vector<int> a;
  for (int i = v.size() - 1; i >= 0; --i) {
    if (end == v[i]) {
      a.push_back(i + 1);
      --end;
    }
  }
  std::reverse(a.begin(), a.end());
  std::cout << a.size() << '\n';
  std::cout << a.front();
  for (int i = 1; i < a.size(); ++i) {
    std::cout << ' ' << a[i];
  }
  std::cout << '\n';
  return 0;
}
