#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<tuple<int, int, int> > v;
  int x;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    v.push_back({x, i + 1, 0});
  }
  sort((v).begin(), (v).end());
  stack<int> s;
  string passengers;
  cin >> passengers;
  int itr = 0;
  for (int i = 0; i < (int)passengers.length(); ++i) {
    if (passengers[i] == '0') {
      if (get<2>(v[itr]) < 1) {
        get<2>(v[itr]) = 1;
        cout << get<1>(v[itr]) << ' ';
        s.push(get<1>(v[itr]));
      } else {
        itr++;
        get<2>(v[itr]) = 1;
        cout << get<1>(v[itr]) << ' ';
        s.push(get<1>(v[itr]));
      }
    } else {
      cout << s.top() << ' ';
      s.pop();
    }
  }
  return 0;
}
