#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = ((x % p) * (x % p)) % p;
  }
  return res % p;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p) % p;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int>> v;
  map<long long int, long long int> m;
  for (long long int i = 1; i <= n; i++) {
    long long int x;
    cin >> x;
    v.push_back(make_pair(x, i));
    m[x] = i;
  }
  sort((v).begin(), (v).end());
  string s;
  cin >> s;
  long long int in = 0, ex = 0;
  priority_queue<long long int> pq;
  for (long long int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      cout << v[in].second << " ";
      pq.push(v[in].first);
      in++;
    }
    if (s[i] == '1') {
      cout << m[pq.top()] << " ";
      pq.pop();
    }
  }
  return 0;
}
