#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(make_pair(x, i + 1));
  }
  sort(v.begin(), v.end());
  string s;
  cin >> s;
  if (n == 1) {
    cout << 1 << " " << 1 << endl;
    return 0;
  }
  int a = 0;
  stack<int> q;
  vector<int> ans;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0') {
      int x = v[a].second;
      a++;
      q.push(a - 1);
      cout << x << " ";
    } else {
      int b = q.top();
      int x = v[b].second;
      q.pop();
      cout << x << " ";
    }
  }
  cout << endl;
  return 0;
}
