#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n];
  pair<long long int, long long int> p[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    p[i] = make_pair(a[i], i);
  }
  sort(p, p + n);
  string s;
  cin >> s;
  stack<long long int> s1;
  int j = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      cout << p[j].second + 1 << " ";
      s1.push(p[j].second);
      j++;
    } else {
      cout << s1.top() + 1 << " ";
      s1.pop();
    }
  }
}
