#include <bits/stdc++.h>
using namespace std;
string s;
pair<long long, long long> p[200005];
stack<long long> st;
int main() {
  long long m, n, t, b, c, d, i, j, k, x, y, z, l, q, r;
  long long cnt = 0, ans = 0;
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) {
    cin >> x;
    p[i] = make_pair(x, i);
  }
  cin >> s;
  sort(p, p + n);
  j = 0;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      cout << p[j].second + 1 << " ", st.push(p[j].second), j++;
    } else {
      cout << st.top() + 1 << " ", st.pop();
    }
  }
  return 0;
}
