#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    
    // Aloca memoria fixa
    int arr[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    
    // Passada 1: Conta os 0s
    int c0 = 0;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == 0) c0++;
    }
    cout << c0 << "\n";
    
    // Passada 2: Imprime os 0s
    bool first = true;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == 0) {
            if (!first) cout << " ";
            cout << i;
            first = false;
        }
    }
    cout << "\n";
    
    // Passada 3: Conta os 1s
    int c1 = 0;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == 1) c1++;
    }
    cout << c1 << "\n";
    
    // Passada 4: Imprime os 1s
    first = true;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == 1) {
            if (!first) cout << " ";
            cout << i;
            first = false;
        }
    }
    cout << "\n";
    
    return 0;
}
