#include <bits/stdc++.h>
using namespace std;
long long in() {
  long long a;
  scanf("%lld", &a);
  return a;
}
int main() {
  int t = 1;
  while (t--) {
    long long n = in();
    vector<pair<long long, long long> > V;
    for (int i = 1; i <= n; i++) {
      long long w = in();
      V.push_back({w, i});
    }
    string s;
    cin >> s;
    sort(V.begin(), V.end());
    stack<long long> q;
    vector<long long> res;
    for (int i = 0, l = 0; i < s.size(); i++) {
      int c = s[i] - '0';
      if (c == 0) {
        res.push_back(V[l].second);
        q.push(V[l++].second);
      } else if (c == 1) {
        res.push_back(q.top());
        q.pop();
      }
    }
    for (int i = 0; i < res.size(); i++) cout << res[i] << " ";
    cout << endl;
  }
  return 0;
}
