#include <bits/stdc++.h>
using namespace std;
const long long N = 500000 + 5;
long long n, t = 1, res[N], cnt[N];
pair<long long, long long> a[N];
deque<long long> Q;
string s;
void Input() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long p;
    cin >> p;
    a[i].first = p;
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  cin >> s;
}
void Solve() {
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      Q.push_back(a[t].second);
      res[i] = a[t].second;
      t++;
    } else {
      res[i] = Q.back();
      Q.pop_back();
    }
  }
  for (int i = 0; i < s.size(); i++) cout << res[i] << " ";
}
int main() {
  Input();
  Solve();
  return 0;
}
