#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, y = 0;
  cin >> n;
  string yy;
  vector<string> arr;
  stack<string> st;
  for (long long int i = 0; i < n; i++) {
    long long int tt;
    cin >> tt;
    string h = to_string(tt), h1, t = to_string(i + 1);
    for (long long int j = 0; j < 10 - h.length(); j++) h1 = h1 + "0";
    arr.push_back(h1 + h + "a" + t);
  }
  sort(arr.begin(), arr.end());
  cin >> yy;
  for (long long int i = 0; i < 2 * n; i++) {
    if (yy[i] == '0') {
      if (y == n) break;
      string top = arr[y];
      st.push(arr[y]);
      for (long long int j = 11; j < top.length(); j++) cout << top[j];
      cout << " ";
      y++;
    } else {
      if (st.empty()) {
        cout << 0 << " ";
        continue;
      }
      string top = st.top();
      for (long long int j = 11; j < top.length(); j++) cout << top[j];
      st.pop();
      cout << " ";
    }
  }
  return 0;
}
