#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, j;
  cin >> n;
  vector<pair<long long int, long long int> > v;
  v.resize(n);
  long long int w[n];
  for (i = 0; i < n; i++) {
    cin >> v[i].first;
    v[i].second = (i + 1);
  }
  sort(v.begin(), v.end());
  bool taken[n + 1];
  for (i = 0; i <= n; i++) {
    taken[i] = false;
  }
  int ex = (n - 1), in = 0;
  string str;
  stack<int> s;
  cin >> str;
  for (i = 0; i < str.length(); i++) {
    if (str[i] == '0') {
      cout << v[in].second << " ";
      s.push(in);
      in++;
    } else {
      if (s.size() == 0) {
        if (taken[ex] == false) {
          taken[ex] = true;
          cout << v[ex].second << " ";
          ex--;
        }
      } else {
        int temp = s.top();
        taken[temp] = true;
        s.pop();
        cout << v[temp].second << " ";
      }
    }
  }
  return 0;
}
