#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> a[200005];
stack<int> sk;
string s;
int main() {
  cin >> n;
  int w;
  for (int i = 0; i < n; i++) {
    cin >> w;
    a[i] = {w, i + 1};
  }
  sort(a, a + n);
  cin >> s;
  int c = 0;
  int beta[n + 1];
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      cout << a[c].second << (i != 2 * n - 1 ? " " : "\n");
      sk.push(a[c].second);
      c++;
    } else {
      int r = sk.top();
      cout << r << (i != 2 * n - 1 ? " " : "\n");
      sk.pop();
    }
  }
  return 0;
}
