#include <bits/stdc++.h>
using namespace std;
int n;
string st;
map<int, int> s0, s1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0, t; i < n; ++i) {
    cin >> t;
    s0[t] = i + 1;
  }
  cin >> st;
  for (auto c : st) {
    if (c == '0') {
      pair<int, int> t = *s0.begin();
      s0.erase(s0.begin());
      s1.insert(t);
      cout << t.second << " ";
    } else {
      map<int, int>::iterator i = s1.end();
      --i;
      pair<int, int> t = *i;
      s1.erase(i);
      cout << t.second << " ";
    }
  }
}
