#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> v;
priority_queue<pair<int, int>> pq;
string str;
int n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int ptr = 0;
  cin >> n;
  v.resize(n);
  for (auto &i : v) {
    cin >> i.first;
    i.second = ++ptr;
  }
  cin >> str;
  ptr = 0;
  sort(begin(v), end(v));
  for (auto p : str) {
    switch (p) {
      case '0': {
        pq.push(v[ptr]);
        cout << v[ptr].second << ' ';
        ptr += 1;
        break;
      }
      case '1': {
        cout << pq.top().second << ' ';
        pq.pop();
        break;
      }
    }
  }
  cout << endl;
  return 0;
}
