#include <bits/stdc++.h>
using namespace std;
struct s {
  long long int val;
  long long int index;
};
bool comp(s s1, s s2) { return s1.val < s2.val; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, n, i, j, flag = 1, zer = 0, one = 0, no, ni;
  cin >> n;
  string str;
  stack<int> st;
  s arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i].val;
    arr[i].index = i + 1;
  }
  sort(arr, arr + n, comp);
  no = 0;
  ni = 0;
  cin >> str;
  for (i = 0; i < str.length(); i++) {
    if (str[i] == '0') {
      cout << arr[ni].index << " ";
      st.push(ni);
      ni++;
    } else {
      no = st.top();
      cout << arr[no].index << " ";
      st.pop();
    }
  }
  cout << endl;
  return 0;
}
