#include <bits/stdc++.h>
using namespace std;
int arr[1000010];
char ch[1000010];
map<int, int> mp, mp1;
vector<int> vec(1000010);
int main() {
  int i, j, k, n, m, t, p, cas = 1;
  memset(arr, 0, sizeof arr);
  vec.clear();
  mp.clear();
  mp1.clear();
  int cnt = 0, l = 0, r = 0;
  stack<int> st;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    mp[arr[i]] = i + 1;
  }
  getchar();
  scanf("%s", &ch);
  sort(arr, arr + n);
  int len = strlen(ch);
  for (i = 0; i < len; i++) {
    if (ch[i] == '0') {
      cnt++;
      st.push(cnt - 1);
      vec.push_back(mp[arr[cnt - 1]]);
    } else {
      int n1 = st.top();
      st.pop();
      vec.push_back(mp[arr[n1]]);
    }
  }
  for (i = 0; i < vec.size(); i++) {
    if (i == 0)
      printf("%d", vec[i]);
    else
      printf(" %d", vec[i]);
  }
  printf("\n");
  return 0;
}
