#include <bits/stdc++.h>
using namespace std;
int a[100005];
string b;
int main() {
  ios_base::sync_with_stdio(0);
  ;
  cin.tie(0);
  cout.tie(0);
  int i, n, j, l = -4e9, r = 4e9;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  cin >> b;
  for (i = 4; i < n; i++) {
    if (b[i] == b[i - 1]) continue;
    if (b[i] == '0')
      r = min(
          r,
          min(a[i], min(a[i - 1], min(a[i - 2], min(a[i - 3], a[i - 4])))) - 1);
    else
      l = max(
          l,
          max(a[i], max(a[i - 1], max(a[i - 2], max(a[i - 3], a[i - 4])))) + 1);
  }
  cout << max(l, -1000000000) << " " << min(r, 1000000000);
  return 0;
}
