#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long a, long long b) {
  if (b == 0) return 1;
  if (!(b & 1)) {
    long long ret = bigmod(a, b / 2);
    return ((ret % 1000000007) * (ret % 1000000007)) % 1000000007;
  } else
    return ((a % 1000000007) * (bigmod(a, b - 1) % 1000000007)) % 1000000007;
}
bool cmp(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first != p2.first) return p1.first < p1.first;
  return p1.second < p2.second;
}
bool approximatelyEqual(float a, float b, float epsilon) {
  return fabs(a - b) <= ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool essentiallyEqual(float a, float b, float epsilon) {
  return fabs(a - b) <= ((fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool definitelyGreaterThan(float a, float b, float epsilon) {
  return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool definitelyLessThan(float a, float b, float epsilon) {
  return (b - a) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool cmp1(pair<int, int> p1, pair<int, int> p2) {
  return p1.second < p2.second;
}
bool cmp2(pair<int, int> p1, pair<int, int> p2) {
  return p1.second > p2.second;
}
int main() {
  int t, tc = 1, a, b, c, m, n, i, j, k, p, q;
  char s[500000];
  vector<pair<int, int> > u, v;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &c);
    u.push_back(pair<int, int>(i, c));
    v.push_back(pair<int, int>(i, c));
  }
  getchar();
  scanf("%s", s);
  sort(u.begin(), u.end(), cmp1);
  k = 0, b = 0;
  vector<int> ans;
  stack<int> st;
  int oc[200001] = {0};
  int pp;
  for (i = 0; s[i]; i++) {
    if (s[i] == '0') {
      ans.push_back(u[k].first + 1);
      st.push(k);
      k++;
    } else {
      int xx = st.top();
      st.pop();
      ans.push_back(u[xx].first + 1);
    }
  }
  for (i = 0; i < ans.size(); i++) {
    i != ans.size() - 1 ? printf("%d ", ans[i]) : printf("%d\n", ans[i]);
  }
  return 0;
}
