#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    ifstream cin("race.in");
    ofstream cout("race.out");
    int n;
    cin >> n;
    int ma = 0;
    vector<int> ans;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        ma = max(ma, x);
        if (ma == i) ans.push_back(i);
    }
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++)
        cout << ans[i] << ((ans.size() == i + 1) ? '\n' : ' ');
}