#include <bits/stdc++.h>
using namespace std;
bool op(std::pair<int, int> p1, std::pair<int, int> p2) {
  return p1.second < p2.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<std::pair<int, int> > seats;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    seats.emplace_back(i, temp);
  }
  sort(seats.begin(), seats.end(), op);
  deque<std::pair<int, int> > q;
  string s;
  cin >> s;
  int i = 0;
  for (char c : s) {
    if (c == '0') {
      cout << seats[i].first + 1 << " ";
      q.push_back(seats[i]);
      i++;
    } else {
      std::pair<int, int> p = q.back();
      q.pop_back();
      cout << p.first + 1 << " ";
    }
  }
}
