#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 10;
pair<int, int> a[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].first), a[i].second = i;
  sort(a + 1, a + n + 1);
  priority_queue<pair<int, int> > pq;
  int j = 1, fst = 1;
  for (int i = 1; i <= n * 2;) {
    char ch;
    ch = getchar();
    if (ch == '\n') continue;
    if (fst == 1)
      fst = 0;
    else
      printf(" ");
    if (ch == '0')
      pq.push(a[j]), printf("%d", a[j++].second);
    else
      printf("%d", pq.top().second), pq.pop();
    i++;
  }
  cout << endl;
  return 0;
}
