#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int x, a;
  cin >> x;
  map<int, int> m;
  for (int i = 0; i < x; ++i) {
    cin >> a;
    m[a] = i + 1;
  }
  string t;
  cin >> t;
  auto it = m.begin();
  vector<int> s;
  auto bit = s.rbegin();
  for (int i = 0; i < t.length(); ++i) {
    if (t[i] == '0') {
      cout << it->second << " ";
      s.push_back(it->second);
      it++;
    } else {
      cout << s[s.size() - 1] << " ";
      s.pop_back();
    }
  }
}
