#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  pair<int, int> w[200007];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> w[i].first;
    w[i].second = i;
  }
  sort(w, w + n);
  string s;
  cin >> s;
  vector<int> ext;
  int iterator = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      cout << w[iterator].second + 1 << " ";
      ext.push_back(w[iterator].second + 1);
      iterator++;
    } else {
      int ans = *(ext.end() - 1);
      ext.erase(ext.end() - 1);
      cout << ans << " ";
    }
  }
}
