#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<pair<int, int>> width;
  for (int i = 1; i <= n; ++i) {
    int w;
    cin >> w;
    width.push_back({w, i});
  }
  string p;
  cin >> p;
  sort(width.begin(), width.end(),
       [](const pair<int, int> &a, const pair<int, int> &b) {
         return a.first < b.first;
       });
  int i = 0;
  stack<int> s;
  for (char c : p) {
    if (c == '0') {
      cout << (width[i].second) << " ";
      s.push(width[i].second);
      ++i;
    } else {
      cout << (s.top()) << " ";
      s.pop();
    }
  }
  cout << endl;
  return 0;
}
