#include <bits/stdc++.h>
using namespace std;
struct st {
  long long int num;
  long long int big;
} w[200001];
bool cmp(st a, st b) { return a.big < b.big; }
int main() {
  std::ios::sync_with_stdio(false);
  long long int n, i;
  char p;
  while (cin >> n) {
    queue<long long int> q;
    stack<st> ss;
    for (i = 0; i < n; i++) {
      cin >> w[i].big;
      w[i].num = i + 1;
    }
    long long int t = 0;
    sort(w, w + n, cmp);
    for (i = 0; i < 2 * n; i++) {
      cin >> p;
      if (p == '0') {
        q.push(w[t].num);
        ss.push(w[t]);
        t++;
      }
      if (p == '1') {
        st a;
        a = ss.top();
        q.push(a.num);
        ss.pop();
      }
    }
    while (!q.empty()) {
      cout << q.front() << " ";
      q.pop();
    }
    cout << endl;
  }
  return 0;
}
