#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1, -1, 1, 1, -1};
int dy[] = {1, 0, -1, 0, -1, -1, 1, 1};
int kx[] = {-2, -2, -1, 1, 2, 2, 1, -1};
int ky[] = {-1, 1, 2, 2, 1, -1, -2, -2};
inline long long gcd(long long a, long long b) {
  a = fabs(a);
  b = fabs(b);
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1 % m, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
struct DATA {
  long long w, no;
};
stack<DATA> s;
vector<DATA> v;
bool cmp(DATA A, DATA B) { return A.w < B.w; }
int main() {
  long long n;
  DATA data;
  scanf("%lld", &n);
  for (int i = (int)(1); i <= (int)(n); i++) {
    long long x;
    scanf("%lld", &x);
    data.w = x;
    data.no = i;
    v.push_back(data);
  }
  sort(v.begin(), v.end(), cmp);
  long long nn = n + n;
  long long in = 0;
  getchar();
  for (int i = (int)(1); i <= (int)(nn); i++) {
    char x = getchar();
    if (x == '0') {
      data = v[in++];
      printf("%lld ", data.no);
      s.push(data);
    } else if (x == '1') {
      data = s.top();
      printf("%lld ", data.no);
      s.pop();
    }
  }
  return 0;
}
