#include <bits/stdc++.h>
using namespace std;
struct p {
  int v;
  int in;
} a[200005];
int cmp(p a, p b) { return a.v < b.v; }
int main() {
  int n;
  int cnt = 0, ans = 0;
  vector<p> vv;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i].v), a[i].in = i + 1;
  sort(a, a + n, cmp);
  string x;
  cin >> x;
  for (int i = 0; i != x.size(); i++) {
    if (x[i] == '0') {
      printf("%d ", a[cnt++].in);
      vv.push_back(a[cnt - 1]);
    } else if (x[i] == '1') {
      printf("%d ", vv[vv.size() - 1].in);
      vv.pop_back();
    }
  }
  return 0;
}
