#include <bits/stdc++.h>
using namespace std;
void oj() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  map<long long, long long> mp;
  long long maxi = -1, start = -1;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]] = 1 + mp[v[i] - 1];
    if (mp[v[i]] > maxi) {
      maxi = mp[v[i]];
      start = v[i];
    }
  }
  cout << maxi << "\n";
  start = start - maxi + 1;
  for (long long i = 0; i < n; i++) {
    if (v[i] != start) continue;
    cout << i + 1 << " ";
    start++;
  }
}
signed main() {
  oj();
  solve();
  return 0;
}
