#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e9 + 5;
const long long int MOD = 998244353;
using namespace std;
void solve() {
  int n;
  cin >> n;
  pair<int, int> a[n];
  vector<int> b;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[i] = make_pair(x, i);
  }
  string s;
  cin >> s;
  sort(a, a + n);
  int j = 0;
  stack<int> st;
  for (char i : s) {
    if (i == '0') {
      cout << a[j].second + 1 << " ";
      st.push(a[j].second);
      j++;
    } else {
      cout << st.top() + 1 << " ";
      st.pop();
    }
  }
}
int main() {
  solve();
  return 0;
}
